package me.zhengjie.modules.transfer.factory.service.Impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.account.mapper.AccountCommonMapper;
import me.zhengjie.modules.account.service.AccountAc51Service;
import me.zhengjie.modules.account.service.AccountService;
import me.zhengjie.modules.basic.service.BasicAc02Service;
import me.zhengjie.modules.transfer.factory.service.TransCheckService;
import me.zhengjie.modules.transfer.factory.vo.*;
import me.zhengjie.tool.*;
import me.zhengjie.vo.Constant;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;

/**
 * 转出校验类实现类
 */
@Service
@RequiredArgsConstructor
public class TransCheckServiceImpl implements TransCheckService {

    private  final AccountAc51Service accountAc51Service;
    private  final BasicAc02Service basicAc02Service;
    private final AccountCommonMapper accountCommonMapper;

    /**
     * 转入申请基本信息校验
     * 暂停缴费
     *
     * @param aac001 个人编号
     */
    @Override
    public void TransferApplyBasicCheck(String aac001) {

        MyMap QMap = new MyMap();
        QMap.put("aac001", aac001);
        QMap.put("aac320", Constant.AAC320_1_YX);
//            List<Map> ac01List = NationalQueryRegister.einpBasicinfoQueryService().getAC01(QMap);
        List<Map> ac01List = new ArrayList<>();
        if (ValidateUtil.isEmpty(ac01List) || ac01List.size() > 1) {
            throw new IllegalArgumentException("人员存在多条基本信息！");
        }

    }


    /**
     * 校验人员的参保缴费状态是否为
     * 暂停缴费
     *
     * @param aac001 个人编号
     * @param aae140 险种类型
     */
    @Override
    public void checkAac031(String aac001, String aae140, String aab359) {
        Map map = new HashMap();
        map.put("aac001", aac001);
        map.put("aae140", aae140);
        map.put("aac008", Constant.AAC008_1_ZCCB);
        if (ValidateUtil.isNotEmpty(aab359)) {
            map.put("aab359", aab359);
        }
       List<Map> ac02 = accountCommonMapper.getAc02(map);
        NPETool.isEmptyThrowException(ac02, "参保信息");
        if (!Constant.AAC031_2_ZTJF.equals(ac02.get(0).get("aac031"))) {
            throw new IllegalArgumentException("人员还未暂停缴费");
        }
    }


    /**
     * 校验人员的离退休标识（企业机关同时存在的省份，需要判断险种是否终止缴费）
     *
     * @param aac001 个人编号
     * @param aae140 险种类型
     */
    @Override
    public Map checkAac084(String aac001, String aae140) {
        MyMap QMap = new MyMap();
        QMap.put("aac001", aac001);
        QMap.put("aac320", Constant.AAC320_1_YX);
        List<Map> ac01List = accountCommonMapper.queryAc01Ac02(QMap);
        NPETool.isEmptyThrowException(ac01List, "个人基础信息！");
        if (Constant.AAC084_1_S.equals(ac01List.get(0).get("aac084"))) {
            //需要判断险种对应ac02是否终止缴费，终止缴费才算作退休
            QMap.put("aae140", aae140);
                List<Map> ac02s = accountCommonMapper.getAc02(QMap);
            NPETool.isEmptyThrowException(ac02s, "个人参保信息！");
        }

        return ac01List.get(0);
    }


    /**
     * 校验人员是否有欠费
     *
     * @param aac001 个人编号
     * @param aae140 险种类型
     */
    @Override
    public void checkQF(String aac001, String aae140) {
        Map map = new HashMap();
        map.put("aac001", aac001);
        map.put("aae140", aae140);
        map.put("aae078", Constant.AAE078_0_F);
        if (Constant.AAE140_110_QYZGJBYLBX.equals(aae140) || Constant.AAE140_120_JGSYDWGZRYJBYLBX.equals(aae140) || Constant.AAE140_180_ZYNJ.equals(aae140)) {

            List<String> aae792s = new ArrayList<>();
            aae792s.add(Constant.AAE792_01_ZC);
            aae792s.add(Constant.AAE792_04_QKQQ);
            // aae792s.add(Constant.AAE792_05_TF);
            map.put("aae792s", aae792s);

//                List<Map> ac43 = NationalQueryRegister.einpCollectionQueryService().queryAc43ForOut(map);
            List<Map> ac43 = new ArrayList<>();

            if (!ValidateUtil.isEmpty(ac43)) {
                StringBuffer sb = new StringBuffer();
                sb.append(ListUtil.listMap2ListString(ac43, "aae003"));
                String aae140msg = null;
                if (Constant.AAE140_110_QYZGJBYLBX.equals(aae140)) {
                    aae140msg = "企业养老";
                } else if (Constant.AAE140_120_JGSYDWGZRYJBYLBX.equals(aae140)) {
                    aae140msg = "机关养老";
                } else if (Constant.AAE140_180_ZYNJ.equals(aae140)) {
                    aae140msg = "职业年金";
                }
                throw new IllegalArgumentException("人员" + aae140msg + sb + "期存在欠费，请核实");
            }
        }
    }


    /**
     * 校验人员是否有重复缴费
     *
     * @param aac001 个人编号
     * @param aae140 险种类型
     */
    @Override
    public void checkCFJF(String aac001, String aae140) {
        Map map = new HashMap();
        map.put("aac001", aac001);
        map.put("aae140", aae140);
        if (Constant.AAE140_110_QYZGJBYLBX.equals(aae140) || Constant.AAE140_120_JGSYDWGZRYJBYLBX.equals(aae140)) {
//                List<Map> ac08s = NationalQueryRegister.einpCollectionQueryService().queryAc08(map);
            List<Map> ac08s = new ArrayList<>();
            //云南本地数据 处理 ，不影响其他地方
            ac08s = ac08s.stream().filter(ac08 -> !Constant.AAE793_9024_JZQJFYS.equals(ac08.get("aae793"))).collect(Collectors.toList());
            Map<String, List<Map>> groupByAae003 = ac08s.stream().collect(Collectors.groupingBy(ac08 -> ac08.get("aae003").toString()));
            StringBuilder sb = new StringBuilder();
            for (String aae003 : groupByAae003.keySet()) {
                Integer aae202 = 0;
                List<Map> list = groupByAae003.get(aae003);
                String error = "";
                for (Map aae003Map : list) {
                    aae202 = aae202 + Integer.parseInt(aae003Map.get("aae202") + "");   //aae003改为aae02 以月数判断是否重复缴费
                    if ("9022".equals(aae003Map.get("aae793").toString())) {
                        error = aae003Map.get("aae003").toString() + "期【" + aae003Map.get("aae794").toString() + "】重复，请到个人账户修改功能，点击生成明细;";
                    } else {
                        error = aae003Map.get("aae003").toString() + "期【" + aae003Map.get("aae794").toString() + "】重复,请核实;";

                    }
                }
                if (aae202 > 1) {
                    sb.append(error);
                    //  throw new IllegalArgumentException("人员存在重复缴费");
                }
            }
            if (sb.length() > 0) {
                throw new IllegalArgumentException(sb.toString());
            }
        }
    }

    /**
     * 校验人员是否有在途业务
     *
     * @param aac001 个人编号
     * @param aaa121 业务功能编号，为空则检查所有在途
     */
    @Override
    public void checkZTYE(String aac001, String aaa121) {
        Map map = new HashMap();
        map.put("aac001", aac001);
        map.put("aae016", Constant.AAE016_0_WSH);
        if (!ValidateUtil.isEmpty(aaa121)) {
            map.put("aaa121", aaa121);
        }
//            List<Map> ae02a1list = RepositoryRegister.businessLogRepository().getAE02A1(map);
        List<Map> ae02a1list = new ArrayList<>();
        if (ValidateUtil.isNotEmpty(ae02a1list)) {
            throw new IllegalArgumentException("人员存在未复核的在途业务:业务类型编码为" + ae02a1list.get(0).get("aaa121"));
        }

    }


    /**
     * 校验是否重复转出
     *
     * @param aae270 联系函编号
     */
    @Override
    public void checkCFZC(String aae270) {
        NPETool.isEmptyThrowException(aae270, "联系函编号");
        Map map = new HashMap();
        map.put("aae270", aae270);
//            Map ac10 = RepositoryRegister.transferRepository().getAC10(map).get(0);
        Map ac10 = new HashMap<>();
        if (!ValidateUtil.isEmpty(ac10) && Constant.AAC306_1_BD.equals(ac10.get("aac306"))) {
            // 存在转出流程 如果最后一条的状态不是 信息表退回的话  是不能再次转出的
            map.put("aaz655", ac10.get("aaz655"));
//                List<Map> ac11s = RepositoryRegister.transferRepository().getAC11(map);
            List<Map> ac11s = new ArrayList<>();
            Collections.sort(ac11s, Comparator.comparing(ac11 -> ac11.get("aaz656").toString()));
            Map ac11 = ac11s.get(ac11s.size() - 1);
            if (!"C0901".equals(ac11.get("aae803"))) {
                throw new IllegalArgumentException("当前联系函已存在转出信息请勿重复转出");
            }
        }
    }

    /**
     * 转入申请：校验是否重复开联系函（同险种，同行政区划）
     *
     * @param aac001 个人编号
     * @param aae140 本方险种
     * @param aae241 对方险种
     * @param aab301 转入地行政区划
     * @param aab299 转出地行政区划
     */
    @Override
    public void checkCFKH(String aac001, String aae140, String aae241, String aab301, String aab299) {
        NPETool.isEmptyThrowException(aac001, "个人编号");
        NPETool.isEmptyThrowException(aae140, "险种类型");
        NPETool.isEmptyThrowException(aae241, "对方险种");
        NPETool.isEmptyThrowException(aab301, "转入地行政区划");
        NPETool.isEmptyThrowException(aab299, "转出地行政区划");
        Map map = new HashMap();
        map.put("aac001", aac001);
        map.put("aac306", Constant.AAC306_1_BD);
        map.put("aab301", aab301);
        map.put("aab299", aab299);
        List<Map> contact = new ArrayList<>();
        if (Constant.AAE140_110_QYZGJBYLBX.equals(aae140) && Constant.AAE140_110_QYZGJBYLBX.equals(aae241)) {
//                contact = NationalQueryRegister.einpEinpSettleQueryService().getIC89NotTransferIn(map);
        } else if (Constant.AAE140_110_QYZGJBYLBX.equals(aae140) && Constant.AAE140_120_JGSYDWGZRYJBYLBX.equals(aae241)) {
//                contact = NationalQueryRegister.einpEinpSettleQueryService().getIC65NotTransferIn(map);
        } else if (Constant.AAE140_110_QYZGJBYLBX.equals(aae140) && Constant.AAE140_170_CXJMJBYLBX.equals(aae241)) {
//                contact = NationalQueryRegister.einpEinpSettleQueryService().getIC71NotTransferIn(map);
        } else if (Constant.AAE140_170_CXJMJBYLBX.equals(aae140) && Constant.AAE140_110_QYZGJBYLBX.equals(aae241)) {
//                contact = NationalQueryRegister.einpEinpSettleQueryService().getIC71NotTransferIn(map);
        } else if (Constant.AAE140_170_CXJMJBYLBX.equals(aae140) && Constant.AAE140_170_CXJMJBYLBX.equals(aae241)) {
//                contact = NationalQueryRegister.einpEinpSettleQueryService().getIC76NotTransferIn(map);
        } else if (Constant.AAE140_120_JGSYDWGZRYJBYLBX.equals(aae140)) {
//                contact = NationalQueryRegister.einpEinpSettleQueryService().getIC65NotTransferIn(map);
        } else if (Constant.AAE140_180_ZYNJ.equals(aae140) || Constant.AAE140_180_ZYNJ.equals(aae241)) {
//                contact = RepositoryRegister.transferRepository().getIc69(map);
        }

        if (ValidateUtil.isNotEmpty(contact)) {
            List<String> aaz341s = new ArrayList<>();
            contact.forEach(c -> {
                if (!ValidateUtil.isEmpty(c.get("aaz341"))) {
                    aaz341s.add(c.get("aaz341").toString());
                }
            });
            map.clear();
            map.put("aaz341s", aaz341s);
            map.put("aae416", Constant.AAE416_C02012_JJYWCX);
//                List<Map> ae82List = MiddleTransferPlatformLightRegister.getTransferPlatformLight().selectAe77Ae82NoStream(map);
            List<Map> ae82List = new ArrayList<>();
            //查询拒绝信息 被拒绝 可以重复开函
            if (ValidateUtil.isEmpty(ae82List)) {
                throw new IllegalArgumentException("当前条件，该人员已开具联系函！");
            }
            if (ae82List.size() != aaz341s.size()) {
                throw new IllegalArgumentException("当前条件，该人员已开具联系函！");
            }
        }


    }

    /**
     * 转入：校验是否已经办理转入申请
     *
     * @param aae270 联系函编号
     * @param aae140 险种类型
     */
    @Override
    public void checkApplication(String aae270, String aae140, String aae241) {

        NPETool.isEmptyThrowException(aae140, "险种类型");
        NPETool.isEmptyThrowException(aae241, "对方险种类型");
        Map map = new HashMap();
        map.put("aae270", aae270);
        map.put("aae016", Constant.AAE016_1_SHTG);

        List<Map> contact = null;
        if (Constant.AAE140_110_QYZGJBYLBX.equals(aae140) && Constant.AAE140_110_QYZGJBYLBX.equals(aae241)) {
//                contact = NationalQueryRegister.einpEinpSettleQueryService().getIC89(map);
        } else if (Constant.AAE140_110_QYZGJBYLBX.equals(aae140) && Constant.AAE140_120_JGSYDWGZRYJBYLBX.equals(aae241)) {
//                contact = NationalQueryRegister.einpEinpSettleQueryService().getIC65(map);
        } else if (Constant.AAE140_110_QYZGJBYLBX.equals(aae140) && Constant.AAE140_170_CXJMJBYLBX.equals(aae241)) {
//                contact = NationalQueryRegister.einpEinpSettleQueryService().getIC71(map);
        } else if (Constant.AAE140_170_CXJMJBYLBX.equals(aae140) && Constant.AAE140_110_QYZGJBYLBX.equals(aae241)) {
//                contact = NationalQueryRegister.einpEinpSettleQueryService().getIC71(map);
        } else if (Constant.AAE140_170_CXJMJBYLBX.equals(aae140) && Constant.AAE140_170_CXJMJBYLBX.equals(aae241)) {
//                contact = NationalQueryRegister.einpEinpSettleQueryService().getIC76(map);
        } else if (Constant.AAE140_120_JGSYDWGZRYJBYLBX.equals(aae140)) {
//                contact = NationalQueryRegister.einpEinpSettleQueryService().getIC65(map);
        } else if (Constant.AAE140_180_ZYNJ.equals(aae140) || Constant.AAE140_180_ZYNJ.equals(aae241)) {
//                contact = RepositoryRegister.transferRepository().getIc69(map);
        }

        if (ValidateUtil.isEmpty(contact)) {
            throw new IllegalArgumentException("未获取到对应的转入申请");
        }
    }

    /**
     * 转入：校验是否已经办理接收临时账户通知书
     *
     * @param aac001 人员编号
     * @param aae270 通知书编号
     */
    @Override
    public void checkNotifition(String aac001, String aae270) {

        NPETool.isEmptyThrowException(aac001, "人员编号");
        NPETool.isEmptyThrowException(aae270, "通知书编号");
        Map map = new HashMap();
        map.put("aac001", aac001);
        map.put("aae270", aae270);

//            List<Map> notifition = NationalQueryRegister.einpEinpSettleQueryService().getIC92(map);
        List<Map> notifition = new ArrayList<>();
        if (!ValidateUtil.isEmpty(notifition)) {
            throw new IllegalArgumentException("该通知书编号，已办理接收业务！");
        }
    }


    /**
     * 校验城乡转城职信息表
     *
     * @param informationInfo
     * @param detailInfos
     */
    @Override
    public void checkInformationOfResidentToStaff(InformationInfo informationInfo, List<InformationDetailInfo> detailInfos) {

        Ic72Info ic72Info = (Ic72Info) informationInfo;

        Integer aae030 = new Integer(ic72Info.getAae030().toString());
        Integer aae031 = new Integer(ic72Info.getAae031().toString());
        Integer aae199 = ic72Info.getAae199();
        BigDecimal aic083 = ic72Info.getAic083();

        NPETool.isEmptyThrowException(aae030, "缴费开始时间");
        NPETool.isEmptyThrowException(aae031, "缴费结束时间");
        NPETool.isEmptyThrowException(aae199, "累计缴费月数");

        if (6 != aae030.toString().length()) {
            throw new IllegalArgumentException("缴费开始时间格式异常");
        }
        Integer nowDate = Integer.valueOf(DateUtil.getCurrentTime("yyyyMM"));
        if (aae030.intValue() > nowDate) {
            throw new IllegalArgumentException("缴费起始时间应小于或等于系统当前时间");
        }

        NPETool.isEmptyThrowException(aae031, "缴费结束时间");
        if (6 != aae031.toString().length()) {
            throw new IllegalArgumentException("缴费结束时间格式异常");
        }

        if (aae030.compareTo(aae031) > 0) {
            throw new IllegalArgumentException("缴费起始时间应小于或等于缴费截止时间");
        }

        NPETool.isEmptyThrowException(aae199, "累计缴费月数");
        if (aae199 < 0 || aae199 > (aae031 - aae030 + 1) * 12) {
            throw new IllegalArgumentException("0≤累计缴费月数≤（缴费截止时间-缴费起始时间＋１）*12");
        }
        NPETool.isEmptyThrowException(aic083, "个人账户基金转移额");
        if (BigDecimal.ZERO.compareTo(aic083) > 0) {
            throw new IllegalArgumentException("个人账户基金转移额应大于0");
        }
        Integer year = DateUtil.getYear(new Date());
        int i = 1;
        Ic73Info ic73;
        List<Integer> allYear = new ArrayList<>();
        // 备注含一次性缴费
        List<Integer> bzhycxjfYear = new ArrayList<>();
        for (int j = 0; j < detailInfos.size(); j++) {
            ic73 = (Ic73Info) detailInfos.get(j);
            //NPETool.isEmptyThrowException(ic73.getAaz341(), "信息表第" + i + "条系统跟踪流水号");
            //if (!this.getAaz341().equals(ic73.getAaz341())) {
            //    throw new IllegalArgumentException("信息表第" + i + "历史信息的系统跟踪流水号必须与基本信息中系统跟踪流水号对应");
            //}
            NPETool.isEmptyThrowException(ic73.getAac001(), "信息表第" + i + "条个人编号");
            NPETool.isEmptyThrowException(ic73.getAab301(), "信息表第" + i + "条转出地行政区划代码");
            NPETool.isEmptyThrowException(ic73.getAae001(), "信息表第" + i + "条年份");
            NPETool.isEmptyThrowException(ic73.getAae382(), "信息表第" + i + "条至本年末账户累计储存额");


            if (ic72Info.getAac001().equals(ic73.getAac001())) {
                throw new IllegalArgumentException("信息表第" + i + "历史信息的个人编号必须与基本信息中个人编号对应");
            }


            if (ic73.getAae001().toString().length() != 4) {
                throw new IllegalArgumentException("信息表第" + i + "条年份格式出错");
            }
            if (ic73.getAae001().intValue() > year) {
                throw new IllegalArgumentException("信息表第" + i + "条年份应早于或等于系统当前年份");
            }

            if (ic73.getAae382().compareTo(BigDecimal.ZERO) < 1) {
                throw new IllegalArgumentException("信息表第" + i + "条至本年末账户累计储存额必须有值且大于0");
            }

            if (ic73.getAae013().contains("一次性缴费")) { // 这个类型 当前暂时没封装
                bzhycxjfYear.add(ic73.getAae001());
            }
            //if (ic73.getAae013().contains("中断缴费") && (!ValidateUtil.isEmpty(ic73.getAaa041()) || !ValidateUtil.isEmpty(ic73.getAic152()) || !ValidateUtil.isEmpty(ic73.getAic151()) || !ValidateUtil.isEmpty(ic73.getAae269()))) {
            //    throw new IllegalArgumentException("信息表第" + i + "条备注“中断缴费”的记录只填写至本年末个人账户累计存储额");
            //}
            allYear.add(ic73.getAae001());
            i++;
        }
        // 校验 年份是否连续
        int beforeTransferYear = Integer.parseInt(ic72Info.getAae035().toString().substring(0, 4));
        if (!(((Ic73Info) detailInfos.get(0)).getAae001().intValue() >= beforeTransferYear)) {
            List<Integer> allAae001 = DateUtil.getBetweenAllYear(((Ic73Info) detailInfos.get(0)).getAae001(), beforeTransferYear - 1);
            for (Integer aae001 : allAae001) {
                if (!allYear.contains(aae001)) {
                    throw new IllegalArgumentException("从历史信息首条记录的缴费年度到调转(转出日期)上年，年份应连续（即不存在没有记录的年份）");
                }
            }
        }

        if (bzhycxjfYear.size() > 15) {
            throw new IllegalArgumentException("备注“一次性缴费”的记录累计年限不能超过15年");
        }
    }

    /**
     * 校验城镇转到城乡的信息表
     *
     * @param informationInfo 信息表
     * @param detailInfos     信息表明细
     */
    @Override
    public void checkInformationOfStaffToResident(InformationInfo informationInfo, List<InformationDetailInfo> detailInfos) {

        Ic74Info ic74Info = (Ic74Info) informationInfo;

        BigDecimal aae030 = ic74Info.getAae030();
        BigDecimal aae031 = ic74Info.getAae031();
        BigDecimal aae199 = ic74Info.getAae199();
        BigDecimal aic083 = ic74Info.getAic083();
        String aae005 = ic74Info.getAae005();
        BigDecimal aae035 = ic74Info.getAae035();

        NPETool.isEmptyThrowException(aae030, "缴费开始时间");
        NPETool.isEmptyThrowException(aae031, "缴费结束时间");
        NPETool.isEmptyThrowException(aae199, "累计缴费月数");
        NPETool.isEmptyThrowException(aic083, "个人账户基金转移额");
        NPETool.isEmptyThrowException(aae035, "转移日期");


        if (6 != aae030.toString().length()) {
            throw new IllegalArgumentException("缴费开始时间格式异常");
        }
        Integer nowDate = Integer.valueOf(DateUtil.getCurrentTime("yyyyMM"));
        if (aae030.intValue() > nowDate) {
            throw new IllegalArgumentException("缴费起始时间应小于或等于系统当前时间");
        }

        if (6 != aae031.toString().length()) {
            throw new IllegalArgumentException("缴费结束时间格式异常");
        }

        if (aae030.compareTo(aae031) > 0) {
            throw new IllegalArgumentException("缴费起始时间应小于或等于缴费截止时间");
        }

        if (BigDecimal.ZERO.compareTo(aae199) > 0 || aae199.compareTo(aae031.subtract(aae030).add(BigDecimal.ONE)) * 12 > 0) {
            throw new IllegalArgumentException("0≤累计缴费月数≤（缴费截止时间-缴费起始时间＋１）*12");
        }
        if (aic083.compareTo(BigDecimal.ZERO) < 1) {
            throw new IllegalArgumentException("个人账户基金转移额应大于0");
        }

        //20211019贵州需求，本地缴费超过15年，不可转至城乡
        if (aae199.compareTo(new BigDecimal("180")) > 0) {
            throw new IllegalArgumentException("累积缴费月数已经超过180个月，不满足转移条件！");
        }

        //20211019贵州需求，根据出生日期和办理转移日期计算年龄，男60女50，不满足不可转出至城乡
        String aac006 = String.valueOf(ic74Info.getAac006()).substring(0, 6) + "01"; // 计算年龄计算到月
        String aac004 = String.valueOf(ic74Info.getAac004());
        Integer nowTime = Integer.valueOf(DateUtil.getCurrentTime("yyyyMMdd"));

        LocalDateTime beginYear = DateUtil.dateToLocalDateTime(DateUtil.str2Date(aac006, "yyyyMMdd"));
        LocalDateTime endYear = DateUtil.dateToLocalDateTime(DateUtil.str2Date(nowTime.toString(), "yyyyMMdd"));

        //if ((Constant.AAC004_1_N.equals(aac004) && age < 60) || (Constant.AAC004_2_N.equals(aac004) && age < 50)) {
        //    throw new IllegalArgumentException("该人员为年龄小于50或60岁人员，不满足转移条件！");
        //}

        Integer year = DateUtil.getYear(new Date());
        int i = 1;
        Ic75Info ic75;
        List<Integer> allYear = new ArrayList<>();

        // 记录上一条数据
        for (int j = 0; j < detailInfos.size(); j++) {
            ic75 = (Ic75Info) detailInfos.get(j);

            NPETool.isEmptyThrowException(ic75.getAac001(), "信息表第" + i + "条个人编号");
            NPETool.isEmptyThrowException(ic75.getAab301(), "信息表第" + i + "条转出地行政区划代码");
            NPETool.isEmptyThrowException(ic75.getAae001(), "信息表第" + i + "条年份");
            NPETool.isEmptyThrowException(ic75.getAae041(), "信息表第" + i + "条缴费起始时间");
            NPETool.isEmptyThrowException(ic75.getAae042(), "信息表第" + i + "条缴费截止时间");
            NPETool.isEmptyThrowException(ic75.getAae202(), "信息表第" + i + "条缴费月数");


            if (!ic74Info.getAac001().equals(ic75.getAac001())) {
                throw new IllegalArgumentException("信息表第" + i + "历史信息的个人编号必须与基本信息中个人编号对应");
            }
            if (ic75.getAae001().toString().length() != 4) {
                throw new IllegalArgumentException("信息表第" + i + "条年份格式出错");
            }
            if (ic75.getAae001().intValue() > year) {
                throw new IllegalArgumentException("信息表第" + i + "条年份应早于或等于系统当前年份");
            }
            allYear.add(ic75.getAae001().intValue());
            if (6 != ic75.getAae041().toString().length()) {
                throw new IllegalArgumentException("信息表第" + i + "条缴费起始时间格式错误 ");
            }

            if (6 != ic75.getAae042().toString().length()) {
                throw new IllegalArgumentException("信息表第" + i + "条缴费结束时间格式错误 ");
            }

            if (!(0 <= ic75.getAae202().intValue() && ic75.getAae202().intValue() <= ic75.getAae042().intValue() - ic75.getAae041().intValue() + 1)) {
                throw new IllegalArgumentException("信息表第" + i + "条月数应≤缴费截止时间-缴费起始时间+1≤12 ");
            }

            i++;
        }
        // 校验 年份是否连续
        int beforeTransferYear = Integer.valueOf(aae035.toString().substring(0, 4)) - 1;
        if (!(((Ic75Info) detailInfos.get(0)).getAae001().intValue() >= beforeTransferYear)) {
            List<Integer> allAae001 = DateUtil.getBetweenAllYear(((Ic75Info) detailInfos.get(0)).getAae001().intValue(), ((Ic75Info) detailInfos.get(detailInfos.size() - 1)).getAae001().intValue());
            for (Integer aae001 : allAae001) {
                if (!allYear.contains(aae001)) {
                    throw new IllegalArgumentException("从历史信息首条记录的缴费起始时间到调转(转出日期)上年，年份应连续（即不存在没有记录的年份）");
                }
            }
        }


    }

    /**
     * 城乡转城乡信息表校验
     *
     * @param informationInfo
     * @param detailInfos
     */
    @Override
    public void checkinfromationOfResident(InformationInfo informationInfo, List<InformationDetailInfo> detailInfos) {

        Ic77Info ic77Info = (Ic77Info) informationInfo;
        Integer aae030 = ic77Info.getAae030();
        Integer aae031 = ic77Info.getAae031();
        Integer aae379 = ic77Info.getAae379();
        BigDecimal aic083 = ic77Info.getAic083();
        String aae035 = ic77Info.getAae035();
        NPETool.isEmptyThrowException(aae030, "缴费开始时间");
        NPETool.isEmptyThrowException(aae031, "缴费结束时间");
        NPETool.isEmptyThrowException(aae379, "累计缴费年限");
        NPETool.isEmptyThrowException(aic083, "转出金额");
        NPETool.isEmptyThrowException(aae035, "转移日期");


        if (6 != aae030.toString().length()) {
            throw new IllegalArgumentException("缴费开始时间格式异常");
        }
        if (6 != aae031.toString().length()) {
            throw new IllegalArgumentException("缴费结束时间格式异常");
        }
        Integer nowDate = Integer.valueOf(DateUtil.getCurrentTime("yyyyMM"));
        if (aae030.intValue() > nowDate) {
            throw new IllegalArgumentException("缴费起始时间应小于或等于系统当前时间");
        }
        if (aae030.compareTo(aae031) > 0) {
            throw new IllegalArgumentException("缴费起始时间应小于或等于缴费截止时间");
        }


        if (aae379 < 0 || (aae379).intValue() > ((aae031.intValue() - aae030.intValue() + 1))) {
            throw new IllegalArgumentException("0≤累计缴费年限≤缴费终止时间的年份-缴费起始时间的年份+1");
        }
        int i = 1;
        //InformationDetailOfResident ic78;
        Ic78Info ic78;
        List<Integer> allYear = new ArrayList<>();
        // 备注含一次性缴费
        List<Integer> bzhycxjfYear = new ArrayList<>();
        Integer year = DateUtil.getYear(new Date());
        String msg = null;
        for (int j = 0; j < detailInfos.size(); j++) {
            try {
                ic78 = (Ic78Info) detailInfos.get(j);
                NPETool.isEmptyThrowException(ic78.getAae001(), "信息表第" + i + "条年份");
                NPETool.isEmptyThrowException(ic78.getAae382(), "信息表第" + i + "条至本年末个人账户累计储存额");

                allYear.add(ic78.getAae001().intValue());
                msg = "信息表第" + i + "条年份格式出错";
                if (ic78.getAae001().toString().length() != 4) {
                    throw new IllegalArgumentException("信息表第" + i + "条年份格式出错");
                }
                msg = "信息表第" + i + "条年份应早于或等于系统当前年份";
                if (ic78.getAae001().intValue() > year) {
                    throw new IllegalArgumentException("信息表第" + i + "条年份应早于或等于系统当前年份");
                }
                msg = "信息表第" + i + "条集体补助如果有值，大于等于0";
                if (!ValidateUtil.isEmpty(ic78.getAic152()) && ic78.getAic152().compareTo(BigDecimal.ZERO) < 0) {
                    throw new IllegalArgumentException("信息表第" + i + "条集体补助如果有值，大于等于0");
                }
                msg = "信息表第" + i + "条其他补助（资助）如果有值，大于等于0";
                if (!ValidateUtil.isEmpty(ic78.getAic153()) && ic78.getAic153().compareTo(BigDecimal.ZERO) < 0) {
                    throw new IllegalArgumentException("信息表第" + i + "条其他补助（资助）如果有值，大于等于0");
                }
                msg = "信息表第" + i + "条个人缴费省级政府补贴到账金额正常缴费的记录中，必须有值，且大于等于0";
                if (ValidateUtil.isEmpty(ic78.getAae013()) && ic78.getAic180().compareTo(BigDecimal.ZERO) < 0) {
                    throw new IllegalArgumentException("信息表第" + i + "条个人缴费省级政府补贴到账金额正常缴费的记录中，必须有值，且大于等于0");
                }
                msg = "信息表第" + i + "条个人缴费市级政府补贴到账金额正常缴费的记录中，必须有值，且大于等于0";
                if (ValidateUtil.isEmpty(ic78.getAae013()) && ic78.getAic181().compareTo(BigDecimal.ZERO) < 0) {
                    throw new IllegalArgumentException("信息表第" + i + "条个人缴费市级政府补贴到账金额正常缴费的记录中，必须有值，且大于等于0");
                }
                msg = "信息表第" + i + "条个人缴费县级政府补贴到账金额正常缴费的记录中，必须有值，且大于等于0";
                if (ValidateUtil.isEmpty(ic78.getAae013()) && ic78.getAic182().compareTo(BigDecimal.ZERO) < 0) {
                    throw new IllegalArgumentException("信息表第" + i + "条个人缴费县级政府补贴到账金额正常缴费的记录中，必须有值，且大于等于0");
                }
                msg = "信息表第" + i + "条利息正常缴费的记录中，必须有值，且大于等于0";
                if (ValidateUtil.isEmpty(ic78.getAae013()) && ic78.getAae269().compareTo(BigDecimal.ZERO) < 0) {
                    throw new IllegalArgumentException("信息表第" + i + "条利息正常缴费的记录中，必须有值，且大于等于0");
                }
                msg = "信息表第" + i + "条其他金额正常缴费的记录中，必须有值，且大于等于0";
                if (ValidateUtil.isEmpty(ic78.getAae013()) && ic78.getAae019().compareTo(BigDecimal.ZERO) < 0) {
                    throw new IllegalArgumentException("信息表第" + i + "条其他金额正常缴费的记录中，必须有值，且大于等于0");
                }
                if (ic78.getAae013().contains("一次性缴费")) {
                    bzhycxjfYear.add(ic78.getAae001().intValue());
                }
//            if (ic78.getAae013().contains("中断缴费") &&
//                    (!ValidateUtil.isEmpty(ic78.getAaa041())
//                            || !ValidateUtil.isEmpty(ic78.getAic152())
//                            || !ValidateUtil.isEmpty(ic78.getAic153())
//                            || !ValidateUtil.isEmpty(ic78.getAic180())
//                            || !ValidateUtil.isEmpty(ic78.getAic181())
//                            || !ValidateUtil.isEmpty(ic78.getAic182())
//                            || !ValidateUtil.isEmpty(ic78.getAae269())
//                            || !ValidateUtil.isEmpty(ic78.getAae019()))) {
//                throw new IllegalArgumentException("信息表第" + i + "条备注“中断缴费”的记录只填写至本年末个人账户累计存储额");
//            }
                i++;
            } catch (Throwable throwable) {
                LogUtil.error(throwable);
                throw new IllegalArgumentException(msg + " 异常：" + throwable.getMessage());
            }
        }
        // 校验 年份是否连续
        int beforeTransferYear = Integer.valueOf(aae035.substring(0, 4)) - 1;
        if (!(((Ic78Info) detailInfos.get(0)).getAae001().intValue() >= beforeTransferYear)) {
            List<Integer> allAae001 = DateUtil.getBetweenAllYear(((Ic78Info) detailInfos.get(0)).getAae001().intValue(), beforeTransferYear);
            for (Integer aae001 : allAae001) {
                if (!allYear.contains(aae001)) {
                    throw new IllegalArgumentException("从历史信息首条记录的缴费起始时间到调转(转出日期)上年，年份应连续（即不存在没有记录的年份）");
                }
            }
        }

        if (bzhycxjfYear.size() > 15) {
            throw new IllegalArgumentException("备注“一次性缴费”的记录累计年限不能超过15年");
        }
    }

    /**
     * 城职信息表校验
     *
     * @param informationInfo    信息表
     * @param informationDetails 信息表明细
     */
    @Override
    public void checkInformationOfStaff(InformationInfo informationInfo, List<InformationDetailInfo> informationDetails) {
        //MyMap informationMyMap = new MyMap(information);

        Ic90Info informationMyMap = (Ic90Info) informationInfo;

        /*校验信息表编号*/
        NPETool.isEmptyThrowException(informationMyMap.getAae405(), "信息表编号");
        /*校验转移账户类别*/
        NPETool.isEmptyThrowException(informationMyMap.getAae473(), "转移账户类别");
        /*校验农民工标识*/
      //  NPETool.isEmptyThrowException(informationMyMap.getAac028(), "农民工标识");
        /*校验出生日期*/
        NPETool.isEmptyThrowException(informationMyMap.getAac006(), "出生日期");
        /*校验转出单位名称*/
        NPETool.isEmptyThrowException(informationMyMap.getAab004(), "转出单位名称");
        /*校验首次参保年月*/
        NPETool.isEmptyThrowException(informationMyMap.getAac049(), "首次参保年月");
        /*校验转移日期*/
        NPETool.isEmptyThrowException(informationMyMap.getAae035(), "转移日期");
        /*校验在本地缴费起始时间*/
        NPETool.isEmptyThrowException(informationMyMap.getAae030(), "在本地缴费起始时间");
        /*校验在本地缴费结束时间*/
        NPETool.isEmptyThrowException(informationMyMap.getAae031(), "在本地缴费结束时间");
        /*校验在本地实际缴费月数*/
        NPETool.isEmptyThrowException(informationMyMap.getAae201(), "在本地实际缴费月数");
        /*校验1998年1月1日前账户中个人缴费累计储存额*/
        NPETool.isEmptyThrowException(informationMyMap.getAic093(), "1998年1月1日前账户中个人缴费累计储存额");
        /*校验1998年1月1日至调转上年末个人账户累计储存额*/
        NPETool.isEmptyThrowException(informationMyMap.getAic089(), "1998年1月1日至调转上年末个人账户累计储存额");
        /*校验调转当年记入个人账户本金金额*/
        NPETool.isEmptyThrowException(informationMyMap.getAic082(), "调转当年记入个人账户本金金额");
        /*校验个人账户基金转移额*/
        NPETool.isEmptyThrowException(informationMyMap.getAic083(), "个人账户基金转移额");
        /*校验统筹基金转移额*/
        NPETool.isEmptyThrowException(informationMyMap.getAic084(), "统筹基金转移额");
        /*校验转移基金总额*/
        NPETool.isEmptyThrowException(informationMyMap.getAic102(), "转移基金总额");
        /*校验行政区划*/
        NPETool.isEmptyThrowException(informationMyMap.getAab301(), "转出地行政区划");
        /*校验行政区划*/
        NPETool.isEmptyThrowException(informationMyMap.getAab299(), "转入地行政区划");


//        if (!aaa102s.contains(informationMyMap.getAab301())) {
//            throw new IllegalArgumentException("信息表基本信息的转出地行政区划"+informationMyMap.getAab301()+"不在中台码表范围内，请核实");
//        }
//        if (!aaa102s.contains(informationMyMap.getAab299())) {
//            throw new IllegalArgumentException("信息表基本信息的转入地行政区划"+informationMyMap.getAab299()+"不在中台码表范围内，请核实");
//        }

        if (8 != informationMyMap.getAac006().toString().length()) {
            throw new IllegalArgumentException("出生日期数据格式错误");
        }
        if (informationMyMap.getAac006().intValue() >= Integer.valueOf(DateUtil.getCurrentTime("yyyyMMdd"))) {
            throw new IllegalArgumentException("出生日期需小于当前时间");
        }
        long age = DateUtil.getAge(DateUtil.stringToDate(informationMyMap.getAac006().toString(), "yyyyMMdd", false));
        if (age < 5 || age > 70) {
            throw new IllegalArgumentException("人员年龄必须在5-70岁之间");
        }
        if (!ValidateUtil.isEmpty(informationMyMap.getAac032()) && (Integer.valueOf(informationMyMap.getAac032() + "01").intValue() <= informationMyMap.getAac006().intValue())) {
            throw new IllegalArgumentException("出生日期需早于个人账户建立日期");
        }
        if (!ValidateUtil.isEmpty(informationMyMap.getAac007()) && (Integer.valueOf(informationMyMap.getAac007() + "01").intValue() <= informationMyMap.getAac006().intValue())) {
            throw new IllegalArgumentException("出生日期需早于参加工作日期");
        }

        /*校验参加工作日期*/
        if (!ValidateUtil.isEmpty(informationMyMap.getAac007()) && 6 != informationMyMap.getAac007().toString().length()) {
            throw new IllegalArgumentException("参加工作日期数据格式错误");
        }
        if (!ValidateUtil.isEmpty(informationMyMap.getAac007()) && informationMyMap.getAac007().intValue() > DateUtil.toIssue(new Date())) {
            throw new IllegalArgumentException("参加工作日期不能晚于当前年月");
        }
        if (!ValidateUtil.isEmpty(informationMyMap.getAac007()) && informationMyMap.getAac007().intValue() > informationMyMap.getAac049().intValue()) {
            throw new IllegalArgumentException("参加工作日期不能晚于首次参保年月");
        }
        if (!ValidateUtil.isEmpty(informationMyMap.getAac007()) && !ValidateUtil.isEmpty(informationMyMap.getAac032()) && informationMyMap.getAac007().intValue() > informationMyMap.getAac032().intValue()) {
            throw new IllegalArgumentException("参加工作日期不能晚于本人建立个人账户时间");
        }
        /*校验首次参保地实行个人缴费时间*/
        if (!ValidateUtil.isEmpty(informationMyMap.getAab305()) && 6 != informationMyMap.getAab305().toString().length()) {
            throw new IllegalArgumentException("首次参保地实行个人缴费时间格式错误");
        }
        if (!ValidateUtil.isEmpty(informationMyMap.getAab305()) && informationMyMap.getAab305().intValue() >= DateUtil.toIssue(new Date())) {
            throw new IllegalArgumentException("首次参保地实行个人缴费时间需早于当前时间");
        }
        /*校验首次参保年月*/
        if (6 != informationMyMap.getAac049().toString().length()) {
            throw new IllegalArgumentException("首次参保年月数据格式错误");
        }
        if (informationMyMap.getAac049().intValue() > DateUtil.toIssue(new Date())) {
            throw new IllegalArgumentException("首次参保年月需早于或等于系统当前年月");
        }
        if (informationMyMap.getAac049().intValue() > informationMyMap.getAae030().intValue()) {
            throw new IllegalArgumentException("首次参保年月需早于或等于在本地缴费起始年月");
        }
        /*校验本人建立个人账户时间*/
        if (!ValidateUtil.isEmpty(informationMyMap.getAac032()) && 6 != informationMyMap.getAac032().toString().length()) {
            throw new IllegalArgumentException("本人建立个人账户时间格式有误");
        }
        if (!ValidateUtil.isEmpty(informationMyMap.getAac032()) && informationMyMap.getAac032().intValue() > DateUtil.toIssue(new Date())) {
            throw new IllegalArgumentException("本人建立个人账户时间需早于或等于系统当前年月");
        }
        if (!ValidateUtil.isEmpty(informationMyMap.getAac032()) && (informationMyMap.getAac032().intValue() < informationMyMap.getAac049().intValue() || informationMyMap.getAac032().intValue() >= DateUtil.toIssue(DateUtil.stringToDate(informationMyMap.getAae035().toString(), "yyyyMMdd", false)))) {
            throw new IllegalArgumentException("本人建立个人账户时间需晚于或等于本人首次缴费时间，且早于转移日期");
        }
        if (!ValidateUtil.isEmpty(informationMyMap.getAac032()) && informationMyMap.getAac032().intValue() < 199101) {
            throw new IllegalArgumentException("本人建立个人账户时间需晚于或等于199101");
        }
        /*校验在本地缴费起始时间*/
        if (6 != informationMyMap.getAae030().toString().length()) {
            throw new IllegalArgumentException("在本地缴费起始时间数据格式错误");
        }
        if (informationMyMap.getAae030().intValue() > informationMyMap.getAae031().intValue()) {
            throw new IllegalArgumentException("在本地缴费起始时间需小于或等于在本地缴费终止时间");
        }
        /*校验在本地缴费终止时间*/
        if (6 != informationMyMap.getAae031().toString().length()) {
            throw new IllegalArgumentException("在本地缴费终止时间数据格式错误");
        }
        if (informationMyMap.getAae031().intValue() > DateUtil.toIssue(new Date())) {
            throw new IllegalArgumentException("在本地缴费终止时间需小于或等于系统当前年月");
        }
        if (informationMyMap.getAae031().intValue() > DateUtil.toIssue(DateUtil.stringToDate(informationMyMap.getAae035().toString(), "yyyyMMdd", false))) {
            throw new IllegalArgumentException("在本地缴费终止时间需小于或等于转移日期");
        }
        /*校验在本地实际缴费月数*/
        if (0 > informationMyMap.getAae201().intValue() || informationMyMap.getAae201().intValue() > DateUtil.getBetweenCountIssue(informationMyMap.getAae030().intValue(), informationMyMap.getAae031().intValue())) {
            throw new IllegalArgumentException("在本地实际缴费月数需大于等于0小于等于开始结束时间之间的月数");
        }
        // 获取历年缴费月数总和
        int totalAae202 = 0;
        BigDecimal tmpAic093 = BigDecimal.ZERO;
        // 获取转移年度
        Integer transferYear = DateUtil.getYear(DateUtil.stringToDate(informationMyMap.getAae035().toString(), "yyyyMMdd", false));
        BigDecimal tmpAic089 = BigDecimal.ZERO;
        BigDecimal tmpAic082 = BigDecimal.ZERO;
        //BigDecimal tmpAccount = BigDecimal.ZERO; // 临时账户统筹金额
        //BigDecimal generalAccount = BigDecimal.ZERO; // 一般账户统筹金额
        BigDecimal tmpAic084 = BigDecimal.ZERO; // 统筹金额

        Ic91Info informationDetail;

        BigDecimal aaa042;
        BigDecimal aaa043;
        BigDecimal aae180;
        BigDecimal aae381;
        BigDecimal aae382;
        BigDecimal aae269;
        BigDecimal aae202;

        Integer aac032 = null;
        if (!ValidateUtil.isEmpty(informationMyMap.getAac032())) {
            aac032 = informationMyMap.getAac032().intValue();
        }

        BigDecimal monthNum;
        BigDecimal tmp_aaa042 = new BigDecimal("0.12");
        for (InformationDetailInfo informationDetailInfo : informationDetails) {
            informationDetail = (Ic91Info) informationDetailInfo;
            aaa042 = ValidateUtil.isEmpty(informationDetail.getAaa042()) ? BigDecimal.ZERO : informationDetail.getAaa042();
            aae180 = ValidateUtil.isEmpty(informationDetail.getAae180()) ? BigDecimal.ZERO : informationDetail.getAae180();
            aae381 = ValidateUtil.isEmpty(informationDetail.getAae381()) ? BigDecimal.ZERO : informationDetail.getAae381();
            aae382 = ValidateUtil.isEmpty(informationDetail.getAae382()) ? BigDecimal.ZERO : informationDetail.getAae382();
            aae269 = ValidateUtil.isEmpty(informationDetail.getAae269()) ? BigDecimal.ZERO : informationDetail.getAae269();
            aaa043 = ValidateUtil.isEmpty(informationDetail.getAaa043()) ? BigDecimal.ZERO : informationDetail.getAaa043();
            aae202 = ValidateUtil.isEmpty(informationDetail.getAae202()) ? BigDecimal.ZERO : informationDetail.getAae202();

            if (aae381.compareTo(BigDecimal.ZERO) > 0 || aae382.compareTo(BigDecimal.ZERO) > 0) {
                if (ValidateUtil.isEmpty(aac032)) {
                    throw new IllegalArgumentException("存在个人账户信息，建立账户时间不能为空！");
                }
            }

            totalAae202 = totalAae202 + aae202.intValue();
            // 去1997年至本年末个人账户个人缴费部分
            if (1997 == informationDetail.getAae001().intValue() && !ValidateUtil.isEmpty(informationDetail.getAae273())) { // 1997存在多条记录只取有金额那条
                tmpAic093 = informationDetail.getAae273();
            }
            // 计算1998-转移前一年个人账户累计存储额
            if (transferYear.intValue() - 1 == informationDetail.getAae001().intValue() && !ValidateUtil.isEmpty(informationDetail.getAae382())) {
                tmpAic089 = tmpAic089.add(informationDetail.getAae382());
            }
            // 计算调转当年记入个人账户本金金额
            if (transferYear.intValue() == informationDetail.getAae001().intValue() || transferYear.toString().equals(informationDetail.getAae001().toString().substring(0, 4))) {

                tmpAic082 = tmpAic082.add(aae381.add(aae269));
            }
            //  计算临时账户和一般账户统筹转移金额
            if (199801 <= informationDetail.getAae041().intValue()) {
                monthNum = new BigDecimal(DateUtil.getBetweenCountIssue(informationDetail.getAae041().intValue(), informationDetail.getAae042().intValue()));

                if (!ValidateUtil.isEmpty(informationDetail.getAae013()) && informationDetail.getAae013().contains("临时缴费账户") || Constant.AAE473_2_LSJFZH.equals((informationMyMap).getAae473())) {

                    if (aaa042.subtract(aaa043).compareTo(new BigDecimal("0.12")) > 0) {
                        tmp_aaa042 = aaa042.subtract(aaa043);
                    }

                    if ((aaa042.subtract(aaa043).compareTo(new BigDecimal("0.12")) == 0) || (aaa042.subtract(aaa043).compareTo(new BigDecimal("0.12"))) < 0) {
                        tmp_aaa042 = new BigDecimal("0.12");
                    }
                }
                tmpAic084 = tmpAic084.add(aae180.multiply(monthNum).multiply(tmp_aaa042));
            }
        }
        if (informationMyMap.getAae201().intValue() > totalAae202) {
            throw new IllegalArgumentException("在本地实际缴费月数需小于或等于历年缴费记录总月数之和");
        }
        /*校验转移日期*/
        if (8 != informationMyMap.getAae035().toString().length()) {
            throw new IllegalArgumentException("转移日期数据格式错误");
        }
        if (informationMyMap.getAae035().intValue() > Integer.valueOf(DateUtil.getCurrentTime("yyyyMMdd"))) {
            throw new IllegalArgumentException("转移日期需小于或等于系统当前日期");
        }

        /*校验1998年1月1日前账户中个人缴费累计储存额*/
        if (BigDecimal.ZERO.compareTo(tmpAic093) > 0) {
            if (0 != informationMyMap.getAic093().compareTo(tmpAic093)) {
                throw new IllegalArgumentException("1998年1月1日前账户中个人缴费累计储存额应等于历史信息中1997年12月所在记录的至本年末账户累计储存额中的个人缴费部分");
            }
        }

        /*校验1998年1月1日至调转上年末个人账户累计储存额*/
        if (0 < informationMyMap.getAic093().add(informationMyMap.getAic089()).compareTo(tmpAic089)) {
            throw new IllegalArgumentException("1998年1月1日前账户中个人缴费累计储存额+1998年1月1日至调转上年末个人账户累计储存额应小于等于历史信息中调转上年12月所在记录的至本年末账户累计储存额");
        }
        /*校验调转当年记入个人账户本金金额*/
        if (0 < informationMyMap.getAic082().compareTo(tmpAic082)) {
            throw new IllegalArgumentException("调转当年记入个人账户本金金额" + informationMyMap.getAic082() + "应小于等于历史信息中调转当年所有记录的当年记账金额+当年记账利息" + tmpAic082);
        }
        /*校验个人账户基金转移额*/
        if (0 != informationMyMap.getAic083().compareTo(informationMyMap.getAic093().add(informationMyMap.getAic089()).add(informationMyMap.getAic082()))) {
            throw new IllegalArgumentException("个人账户基金转移额应等于1998年1月1日前账户中个人缴费累计储存额+1998年1月1日至调转上年末个人账户累计储存额+调转当年记入个人账户本金金额");
        }
        if (!informationMyMap.getAab301().substring(0, 2).equals(informationMyMap.getAab299().substring(0, 2))) {
            /*校验统筹基金转移额*/
            if (informationMyMap.getAic084().compareTo(tmpAic084.add(new BigDecimal("5")).setScale(2, BigDecimal.ROUND_HALF_UP)) > 0
                    && informationMyMap.getAic084().compareTo(tmpAic084.subtract(new BigDecimal("5")).setScale(2, BigDecimal.ROUND_HALF_UP)) < 0) {
                throw new IllegalArgumentException("统筹基金转移额" + informationMyMap.getAic084() + "与计算的金额" + tmpAic084.setScale(2, BigDecimal.ROUND_HALF_UP) + "不一致");
            }
        }

        /*校验转移基金总额*/
        if (0 != informationMyMap.getAic102().compareTo(informationMyMap.getAic083().add(informationMyMap.getAic084()))) {
            throw new IllegalArgumentException("转移基金总额应等于统筹基金转移额+个人账户基金转移额");
        }
    }

    /**
     * 机关信息表校验
     *
     * @param informationInfo    信息表
     * @param informationDetails 信息表明细
     */
    @Override
    public void checkInformationOfOffice(InformationInfo informationInfo, List<InformationDetailInfo> informationDetails) {
        //MyMap informationMyMap = new MyMap(information);

        Ic66Info informationMyMap = (Ic66Info) informationInfo;

        /*校验信息表编号*/
        NPETool.isEmptyThrowException(informationMyMap.getAae405(), "信息表编号");
        /*校验转移账户类别*/
        NPETool.isEmptyThrowException(informationMyMap.getAae473(), "转移账户类别");
        /*校验农民工标识*/
        NPETool.isEmptyThrowException(informationMyMap.getAac028(), "农民工标识");
        /*校验出生日期*/
        NPETool.isEmptyThrowException(informationMyMap.getAac006(), "出生日期");
        /*校验出生日期*/
        NPETool.isEmptyThrowException(informationMyMap.getAac007(), "参加工作日期");
        /*校验转出单位名称*/
        NPETool.isEmptyThrowException(informationMyMap.getAab004(), "转出单位名称");
        /*校验首次参保年月*/
        NPETool.isEmptyThrowException(informationMyMap.getAac049(), "首次参保年月");
        /*校验转移日期*/
        NPETool.isEmptyThrowException(informationMyMap.getAae035(), "转移日期");
        /*校验在本地缴费起始时间*/
        NPETool.isEmptyThrowException(informationMyMap.getAae030(), "在本地缴费起始时间");
        /*校验在本地缴费结束时间*/
        NPETool.isEmptyThrowException(informationMyMap.getAae031(), "在本地缴费结束时间");
        /*校验在本地实际缴费月数*/
        NPETool.isEmptyThrowException(informationMyMap.getAae201(), "在本地实际缴费月数");
        /*校验1998年1月1日前账户中个人缴费累计储存额*/
        NPETool.isEmptyThrowException(informationMyMap.getAic093(), "1998年1月1日前账户中个人缴费累计储存额");
        /*校验1998年1月1日至调转上年末个人账户累计储存额*/
        NPETool.isEmptyThrowException(informationMyMap.getAic089(), "1998年1月1日至调转上年末个人账户累计储存额");
        /*校验调转当年记入个人账户本金金额*/
        NPETool.isEmptyThrowException(informationMyMap.getAic082(), "调转当年记入个人账户本金金额");
        /*校验个人账户基金转移额*/
        NPETool.isEmptyThrowException(informationMyMap.getAic083(), "个人账户基金转移额");
        /*校验统筹基金转移额*/
        NPETool.isEmptyThrowException(informationMyMap.getAic084(), "统筹基金转移额");
        /*校验转移基金总额*/
        NPETool.isEmptyThrowException(informationMyMap.getAic102(), "转移基金总额");
        /*校验行政区划*/
        NPETool.isEmptyThrowException(informationMyMap.getAab301(), "转出地行政区划");
        /*校验行政区划*/
        NPETool.isEmptyThrowException(informationMyMap.getAab299(), "转入地行政区划");

        if (8 != informationMyMap.getAac006().toString().length()) {
            throw new IllegalArgumentException("出生日期数据格式错误");
        }
        if (informationMyMap.getAac006().intValue() >= Integer.valueOf(DateUtil.getCurrentTime("yyyyMMdd"))) {
            throw new IllegalArgumentException("出生日期需小于当前时间");
        }
        long age = DateUtil.getAge(DateUtil.stringToDate(informationMyMap.getAac006().toString(), "yyyyMMdd", false));
        if (age < 5 || age > 70) {
            throw new IllegalArgumentException("人员年龄必须在5-70岁之间");
        }
        if (!ValidateUtil.isEmpty(informationMyMap.getAac032()) && (Integer.valueOf(informationMyMap.getAac032() + "01").intValue() <= informationMyMap.getAac006().intValue())) {
            throw new IllegalArgumentException("出生日期需早于个人账户建立日期");
        }
        if (!ValidateUtil.isEmpty(informationMyMap.getAac007()) && (Integer.valueOf(informationMyMap.getAac007() + "01").intValue() <= informationMyMap.getAac006().intValue())) {
            throw new IllegalArgumentException("出生日期需早于参加工作日期");
        }

        /*校验参加工作日期*/
        if (!ValidateUtil.isEmpty(informationMyMap.getAac007()) && 6 != informationMyMap.getAac007().toString().length()) {
            throw new IllegalArgumentException("参加工作日期数据格式错误");
        }
        if (!ValidateUtil.isEmpty(informationMyMap.getAac007()) && informationMyMap.getAac007().intValue() > DateUtil.toIssue(new Date())) {
            throw new IllegalArgumentException("参加工作日期不能晚于当前年月");
        }
        if (!ValidateUtil.isEmpty(informationMyMap.getAac007()) && informationMyMap.getAac007().intValue() > informationMyMap.getAac049().intValue()) {
            throw new IllegalArgumentException("参加工作日期不能晚于首次参保年月");
        }
        if (!ValidateUtil.isEmpty(informationMyMap.getAac007()) && !ValidateUtil.isEmpty(informationMyMap.getAac032()) && informationMyMap.getAac007().intValue() > informationMyMap.getAac032().intValue()) {
            throw new IllegalArgumentException("参加工作日期不能晚于本人建立个人账户时间");
        }
        /*校验首次参保地实行个人缴费时间*/
        if (!ValidateUtil.isEmpty(informationMyMap.getAab305()) && 6 != informationMyMap.getAab305().toString().length()) {
            throw new IllegalArgumentException("首次参保地实行个人缴费时间格式错误");
        }
        if (!ValidateUtil.isEmpty(informationMyMap.getAab305()) && informationMyMap.getAab305().intValue() >= DateUtil.toIssue(new Date())) {
            throw new IllegalArgumentException("首次参保地实行个人缴费时间需早于当前时间");
        }
        /*校验首次参保年月*/
        if (6 != informationMyMap.getAac049().toString().length()) {
            throw new IllegalArgumentException("首次参保年月数据格式错误");
        }
        if (informationMyMap.getAac049().intValue() > DateUtil.toIssue(new Date())) {
            throw new IllegalArgumentException("首次参保年月需早于或等于系统当前年月");
        }
        if (informationMyMap.getAac049().intValue() > informationMyMap.getAae030().intValue()) {
            throw new IllegalArgumentException("首次参保年月需早于或等于在本地缴费起始年月");
        }
        /*校验本人建立个人账户时间*/
        if (!ValidateUtil.isEmpty(informationMyMap.getAac032()) && 6 != informationMyMap.getAac032().toString().length()) {
            throw new IllegalArgumentException("本人建立个人账户时间格式有误");
        }
        if (!ValidateUtil.isEmpty(informationMyMap.getAac032()) && informationMyMap.getAac032().intValue() > DateUtil.toIssue(new Date())) {
            throw new IllegalArgumentException("本人建立个人账户时间需早于或等于系统当前年月");
        }
        if (!ValidateUtil.isEmpty(informationMyMap.getAac032()) && (informationMyMap.getAac032().intValue() < informationMyMap.getAac049().intValue() || informationMyMap.getAac032().intValue() >= DateUtil.toIssue(DateUtil.stringToDate(informationMyMap.getAae035().toString(), "yyyyMMdd", false)))) {
            throw new IllegalArgumentException("本人建立个人账户时间需晚于或等于本人首次缴费时间，且早于转移日期");
        }
        if (!ValidateUtil.isEmpty(informationMyMap.getAac032()) && informationMyMap.getAac032().intValue() < 199101) {
            throw new IllegalArgumentException("本人建立个人账户时间需晚于或等于199101");
        }
        /*校验在本地缴费起始时间*/
        if (6 != informationMyMap.getAae030().toString().length()) {
            throw new IllegalArgumentException("在本地缴费起始时间数据格式错误");
        }
        if (informationMyMap.getAae030().intValue() > informationMyMap.getAae031().intValue()) {
            throw new IllegalArgumentException("在本地缴费起始时间需小于或等于在本地缴费终止时间");
        }
        /*校验在本地缴费终止时间*/
        if (6 != informationMyMap.getAae031().toString().length()) {
            throw new IllegalArgumentException("在本地缴费终止时间数据格式错误");
        }
        if (informationMyMap.getAae031().intValue() > DateUtil.toIssue(new Date())) {
            throw new IllegalArgumentException("在本地缴费终止时间需小于或等于系统当前年月");
        }
        if (informationMyMap.getAae031().intValue() > DateUtil.toIssue(DateUtil.stringToDate(informationMyMap.getAae035().toString(), "yyyyMMdd", false))) {
            throw new IllegalArgumentException("在本地缴费终止时间需小于或等于转移日期");
        }
        /*校验在本地实际缴费月数*/
        if (0 > informationMyMap.getAae201().intValue() || informationMyMap.getAae201().intValue() > DateUtil.getBetweenCountIssue(informationMyMap.getAae030().intValue(), informationMyMap.getAae031().intValue())) {
            throw new IllegalArgumentException("在本地实际缴费月数需大于等于0小于等于开始结束时间之间的月数");
        }
        // 获取历年缴费月数总和
        int totalAae202 = 0;
        BigDecimal tmpAic093 = BigDecimal.ZERO;
        // 获取转移年度
        Integer transferYear = DateUtil.getYear(DateUtil.stringToDate(informationMyMap.getAae035().toString(), "yyyyMMdd", false));
        BigDecimal tmpAic089 = BigDecimal.ZERO;
        BigDecimal tmpAic082 = BigDecimal.ZERO;
        //BigDecimal tmpAccount = BigDecimal.ZERO; // 临时账户统筹金额
        //BigDecimal generalAccount = BigDecimal.ZERO; // 一般账户统筹金额
        BigDecimal tmpAic084 = BigDecimal.ZERO; // 统筹金额

        Ic67Info informationDetail;

        BigDecimal aaa042;
        BigDecimal aaa043;
        BigDecimal aae180;
        BigDecimal aae381;
        BigDecimal aae382;
        BigDecimal aae269;

        Integer aac032 = null;
        if (!ValidateUtil.isEmpty(informationMyMap.getAac032())) {
            aac032 = informationMyMap.getAac032().intValue();
        }

        BigDecimal monthNum;
        BigDecimal tmp_aaa042 = new BigDecimal("0.12");
        for (InformationDetailInfo informationDetailInfo : informationDetails) {
            informationDetail = (Ic67Info) informationDetailInfo;
            aaa042 = ValidateUtil.isEmpty(informationDetail.getAaa042()) ? BigDecimal.ZERO : informationDetail.getAaa042();
            aae180 = ValidateUtil.isEmpty(informationDetail.getAae180()) ? BigDecimal.ZERO : informationDetail.getAae180();
            aae381 = ValidateUtil.isEmpty(informationDetail.getAae381()) ? BigDecimal.ZERO : informationDetail.getAae381();
            aae382 = ValidateUtil.isEmpty(informationDetail.getAae382()) ? BigDecimal.ZERO : informationDetail.getAae382();
            aae269 = ValidateUtil.isEmpty(informationDetail.getAae269()) ? BigDecimal.ZERO : informationDetail.getAae269();
            aaa043 = ValidateUtil.isEmpty(informationDetail.getAaa043()) ? BigDecimal.ZERO : informationDetail.getAaa043();

            if (aae381.compareTo(BigDecimal.ZERO) > 0 || aae382.compareTo(BigDecimal.ZERO) > 0) {
                if (ValidateUtil.isEmpty(aac032)) {
                    throw new IllegalArgumentException("存在个人账户信息，建立账户时间不能为空！");
                }
            }


            totalAae202 = totalAae202 + informationDetail.getAae202().intValue();
            // 去1997年至本年末个人账户个人缴费部分
            if (1997 == informationDetail.getAae001().intValue() && !ValidateUtil.isEmpty(informationDetail.getAae273())) { // 1997存在多条记录只取有金额那条
                tmpAic093 = informationDetail.getAae273();
            }
            // 计算1998-转移前一年个人账户累计存储额
            if (transferYear.intValue() - 1 == informationDetail.getAae001().intValue() && !ValidateUtil.isEmpty(informationDetail.getAae382())) {
                tmpAic089 = tmpAic089.add(informationDetail.getAae382());
            }
            // 计算调转当年记入个人账户本金金额
            if (transferYear.intValue() == informationDetail.getAae001().intValue() || transferYear.toString().equals(informationDetail.getAae001().toString().substring(0, 4))) {

                tmpAic082 = tmpAic082.add(aae381.add(aae269));
            }

            //  计算临时账户和一般账户统筹转移金额
            if (199801 <= informationDetail.getAae041().intValue()) {
                monthNum = new BigDecimal(DateUtil.getBetweenCountIssue(informationDetail.getAae041().intValue(), informationDetail.getAae042().intValue()));

                if (!ValidateUtil.isEmpty(informationDetail.getAae013()) && informationDetail.getAae013().contains("临时缴费账户") || Constant.AAE473_2_LSJFZH.equals((informationMyMap).getAae473())) {

                    if (aaa042.subtract(aaa043).compareTo(new BigDecimal("0.12")) > 0) {
                        tmp_aaa042 = aaa042.subtract(aaa043);
                    }

                    if ((aaa042.subtract(aaa043).compareTo(new BigDecimal("0.12")) == 0) || (aaa042.subtract(aaa043).compareTo(new BigDecimal("0.12"))) < 0) {
                        tmp_aaa042 = new BigDecimal("0.12");
                    }
                }
                tmpAic084 = tmpAic084.add(aae180.multiply(monthNum).multiply(tmp_aaa042));
            }
        }
        if (informationMyMap.getAae201().intValue() > totalAae202) {
            throw new IllegalArgumentException("在本地实际缴费月数需小于或等于历年缴费记录总月数之和");
        }
        /*校验转移日期*/
        if (8 != informationMyMap.getAae035().toString().length()) {
            throw new IllegalArgumentException("转移日期数据格式错误");
        }
        if (informationMyMap.getAae035().intValue() > Integer.valueOf(DateUtil.getCurrentTime("yyyyMMdd"))) {
            throw new IllegalArgumentException("转移日期需小于或等于系统当前日期");
        }

        /*校验1998年1月1日前账户中个人缴费累计储存额*/
        if (BigDecimal.ZERO.compareTo(tmpAic093) > 0) {
            if (0 != informationMyMap.getAic093().compareTo(tmpAic093)) {
                throw new IllegalArgumentException("1998年1月1日前账户中个人缴费累计储存额应等于历史信息中1997年12月所在记录的至本年末账户累计储存额中的个人缴费部分");
            }
        }

        /*校验1998年1月1日至调转上年末个人账户累计储存额*/
        if (0 < informationMyMap.getAic093().add(informationMyMap.getAic089()).compareTo(tmpAic089)) {
            throw new IllegalArgumentException("1998年1月1日前账户中个人缴费累计储存额+1998年1月1日至调转上年末个人账户累计储存额应小于等于历史信息中调转上年12月所在记录的至本年末账户累计储存额");
        }
        /*校验调转当年记入个人账户本金金额*/
        if (0 < informationMyMap.getAic082().compareTo(tmpAic082)) {
            throw new IllegalArgumentException("调转当年记入个人账户本金金额应小于等于历史信息中调转当年所有记录的当年记账金额+当年记账利息");
        }
        /*校验个人账户基金转移额*/
        if (0 != informationMyMap.getAic083().compareTo(informationMyMap.getAic093().add(informationMyMap.getAic089()).add(informationMyMap.getAic082()))) {
            throw new IllegalArgumentException("个人账户基金转移额应等于1998年1月1日前账户中个人缴费累计储存额+1998年1月1日至调转上年末个人账户累计储存额+调转当年记入个人账户本金金额");
        }

        /*校验统筹基金转移额*/
        if (informationMyMap.getAic084().compareTo(tmpAic084.add(new BigDecimal("5")).setScale(2, BigDecimal.ROUND_HALF_UP)) > 0
                && informationMyMap.getAic084().compareTo(tmpAic084.subtract(new BigDecimal("5")).setScale(2, BigDecimal.ROUND_HALF_UP)) < 0) {
            throw new IllegalArgumentException("统筹基金转移额" + informationMyMap.getAic084() + "与计算的金额" + tmpAic084.setScale(2, BigDecimal.ROUND_HALF_UP) + "不一致");
        }
        /*校验转移基金总额*/
        if (0 != informationMyMap.getAic102().compareTo(informationMyMap.getAic083().add(informationMyMap.getAic084()))) {
            throw new IllegalArgumentException("转移基金总额应等于统筹基金转移额+个人账户基金转移额");
        }
        /*校验账户年月和转出年月是否一致  考虑到转入登记获取不到aaz159 所以转入登记暂不做校验*/
        if (!ValidateUtil.isEmpty(informationMyMap.getAaz159())) {
            Map param = new HashMap();
            param.put("aaz159", informationMyMap.getAaz159());
            param.put("aac001", informationMyMap.getAac001());
            param.put("isNotTf", 1);
            param.put("tyjrzhdy", "1");
            param.put("pclxtqfbj", "1");
//                List<Map> payments = NationalQueryRegister.einpCollectionQueryService().getAC08(param);
            List<Map> payments = new ArrayList<>();
            //因为考虑到建账前的缴费不会显示在信息表月数中，所以比较的的时候，需要排除建账前的缴费
            List<Map> aae003 = payments.stream().filter(m -> new BigDecimal(m.get("aae003").toString()).compareTo(informationMyMap.getAac032()) >= 0).collect(Collectors.toList());
            BigDecimal ac08_aae202 = aae003.stream().map(map -> new BigDecimal(map.get("aae202").toString())).reduce(BigDecimal.ZERO, BigDecimal::add);
            if (informationMyMap.getAae201().compareTo(ac08_aae202) != 0) {
                throw new IllegalArgumentException("个人账户月数和转出月数不一致");
            }
        }
    }

    /**
     * 城职信息表明细校验
     *
     * @param informationInfo    信息表
     * @param informationDetails 信息表明细
     */
    @Override
    public void checkInformationOfStaffDetails(InformationInfo informationInfo, List<InformationDetailInfo> informationDetails) {
        Ic90Info informationMyMap = (Ic90Info) informationInfo;

        Ic91Info informationDetail;
        // 获取调转本年
        Integer year = DateUtil.getYear(DateUtil.stringToDate(informationMyMap.getAae035().toString(), "yyyyMMdd", false));
        List<MyMap> informationDetailMyMaps = new ArrayList<>();
        int i = 1;


        BigDecimal aaa043;
        BigDecimal aaa041;
        BigDecimal aae180;
        BigDecimal aae202;
        BigDecimal aae269;
        BigDecimal aae381;
        BigDecimal aae382;
        String aae013;

        boolean flag = false;


        BigDecimal aae381_cal = BigDecimal.ZERO;//当年记账金额
        //BigDecimal aae264_cal = BigDecimal.ZERO;//当年记账金额中的个人缴费部分


        Integer aac032 = null;
        if (!ValidateUtil.isEmpty(informationMyMap.getAac032())) {
            aac032 = informationMyMap.getAac032().intValue();
        }
        for (InformationDetailInfo detailInfo : informationDetails) {
            informationDetail = (Ic91Info) detailInfo;

            aaa043 = ValidateUtil.isEmpty(informationDetail.getAaa043()) ? BigDecimal.ZERO : informationDetail.getAaa043();
            aaa041 = ValidateUtil.isEmpty(informationDetail.getAaa041()) ? BigDecimal.ZERO : informationDetail.getAaa041();
            aae180 = ValidateUtil.isEmpty(informationDetail.getAae180()) ? BigDecimal.ZERO : informationDetail.getAae180();
            aae269 = ValidateUtil.isEmpty(informationDetail.getAae269()) ? BigDecimal.ZERO : informationDetail.getAae269();
            aae381 = ValidateUtil.isEmpty(informationDetail.getAae381()) ? BigDecimal.ZERO : informationDetail.getAae381();
            aae382 = ValidateUtil.isEmpty(informationDetail.getAae382()) ? BigDecimal.ZERO : informationDetail.getAae382();
            aae202 = ValidateUtil.isEmpty(informationDetail.getAae202()) ? BigDecimal.ZERO : informationDetail.getAae202();
            aae013 = ValidateUtil.isEmpty(informationDetail.getAae013()) ? "" : informationDetail.getAae013();

            if (!ValidateUtil.isEmpty(aac032) && informationDetail.getAae041().intValue() >= aac032) {
                aae381_cal = aae381_cal.add(aae180.multiply(aae202).multiply(aaa043.add(aaa041)));
//                aae264_cal = aae264_cal.add(aae180.multiply(aae202).multiply(aaa041));
                if (aae382.compareTo(BigDecimal.ZERO) > 0) {
                    if (!"曾办理异地转入".equals(aae013)) {
                        if (aae381_cal.setScale(2, BigDecimal.ROUND_HALF_UP).compareTo(aae381.add(BigDecimal.ONE)) > 0) {
                            throw new IllegalArgumentException("缴费明细" + informationDetail.getAae001() + "年,当年记账金额应≥ 基数*比例*月数");
                        }
                    }
                }
                aae381_cal = BigDecimal.ZERO;
            }

            /*校验人员编号*/
            NPETool.isEmptyThrowException(informationDetail.getAac319(), "缴费明细中第" + i + "条人员编号");
            if (!informationMyMap.getAac319().equals(informationDetail.getAac319())) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条人员编号和信息表不一致");
            }
            /*校验转出地行政区划代码*/
            NPETool.isEmptyThrowException(informationDetail.getAab301(), "缴费明细中第" + i + "条转出地行政区划代码");
          /*  if (!informationMyMap.getAab301().equals(informationDetail.getAab301())) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条转出地行政区划代码和信息表不一致");
            }*/
            /*校验参保地行政区划代码*/
            NPETool.isEmptyThrowException(informationDetail.getAab299(), "缴费明细中第" + i + "条参保地行政区划代码");
            /*校验参保地名称*/
            NPETool.isEmptyThrowException(informationDetail.getAab300(), "缴费明细中第" + i + "条参保地名称");
            /*校验年份*/
            NPETool.isEmptyThrowException(informationDetail.getAae001(), "缴费明细中第" + i + "条年份");
            /*校验缴费起始时间  */
            NPETool.isEmptyThrowException(informationDetail.getAae041(), "缴费明细中第" + i + "条缴费起始时间");
            /*校验缴费结束始时间  */
            NPETool.isEmptyThrowException(informationDetail.getAae042(), "缴费明细中第" + i + "条缴费结束时间");
            /*校验缴费月数*/
            NPETool.isEmptyThrowException(informationDetail.getAae202(), "缴费明细中第" + i + "条缴费月数");
            if (4 != informationDetail.getAae001().toString().length() && 6 != informationDetail.getAae001().toString().length()) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条年限格式错误");
            }

            //因为转移当年如果存在基数调整，这个校验就无法通过
          /*  if (6 == informationDetail.getAae001().toString().length() && Integer.valueOf(informationDetail.getAae001().toString().substring(0, 4)) == year) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条格式错误,年限格式为YYYYMM必须是调转当年的补缴记录");
            }*/
            /*校验缴费起始时间  结束始时间*/
            if (6 != informationDetail.getAae041().toString().length()) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条缴费起始时间格式错误");
            }
            if (informationDetail.getAae041().intValue() > DateUtil.toIssue(new Date())) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条缴费起始时间应小于等于当前系统时间");
            }
            if (informationDetail.getAae041().intValue() > informationDetail.getAae042().intValue()) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条缴费起始时间应小于等于缴费结束时间");
            }

            if (6 != informationDetail.getAae042().toString().length()) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条缴费结束始时间错误");
            }
            if (informationDetail.getAae042().intValue() > DateUtil.toIssue(new Date())) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条缴费结束始时间应小于等于当前系统时间");
            }
            if (!informationDetail.getAae041().toString().substring(0, 4).equals(informationDetail.getAae042().toString().substring(0, 4))) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条缴费起始时间和缴费结束时间应在同一年度");
            }
            /*校验缴费月数*/
            if (informationDetail.getAae202().intValue() != DateUtil.getBetweenCountIssue(informationDetail.getAae041().intValue(), informationDetail.getAae042().intValue()) && informationDetail.getAae202().intValue() != 0) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条缴费月数错误");
            }
            /*校验月缴费基数*/
            if ((informationDetail.getAae001().intValue() < 1998 && !aae013.contains("定额缴费"))
                    || informationDetail.getAae001().intValue() > 1997) {
                if (informationDetail.getAae202().intValue() > 0 && aae180.compareTo(BigDecimal.ZERO) < 1) {
                    throw new IllegalArgumentException("缴费明细中第" + i + "条缴费终止时间为1998年1月之前且备注不包含“定额缴费”字样的记录中，以及缴费起始时间为1998年1月及以后的记录中，若缴费月数>0，则月缴费基数>0");
                }
            }
            if (informationDetail.getAae001().intValue() < 1998 && aae013.contains("定额缴费")) {
                if (aae180.compareTo(BigDecimal.ZERO) < 1 && aaa041.compareTo(BigDecimal.ZERO) < 1) {
                    throw new IllegalArgumentException("缴费明细中第" + i + "条缴费终止时间为1998年1月之前且备注含“定额缴费”字样的记录，月缴费基数和个人缴费比例两项之一必须>0");
                }
            }
            /*校验单位缴费比例*/
            if (!(aae013.contains("定额缴费") || aae013.contains("曾办理异地转入")) && informationDetail.getAae202().intValue() > 0) {
                if (!ValidateUtil.isEmpty(aac032) && informationDetail.getAae041().intValue() >= aac032.intValue()) {
                    if (ValidateUtil.isEmpty(informationDetail.getAaa042())) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条除备注含“定额缴费”或“曾办理异地转入”字样的记录外，若缴费月数>0，单位缴费比例必须有值");
                    }
                }
            }

            if (!ValidateUtil.isEmpty(informationDetail.getAaa042())) {
                if (1 > informationDetail.getAaa042().compareTo(BigDecimal.ZERO) || informationDetail.getAaa042().compareTo(BigDecimal.ONE) > -1) {
                    throw new IllegalArgumentException("缴费明细中第" + i + "条单位缴费比例应该大于0小于1");
                }
            }
            /*校验单位缴费划入个人账户比例*/
            if (!ValidateUtil.isEmpty(informationDetail.getAaa043())) {
                if (0 > informationDetail.getAaa043().compareTo(BigDecimal.ZERO) || informationDetail.getAaa043().compareTo(BigDecimal.ONE) > -1) {
                    throw new IllegalArgumentException("缴费明细中第" + i + "条单位缴费划入个人账户比例应该在0-1之间");
                }
                if (!ValidateUtil.isEmpty(informationDetail.getAaa042())) {
                    //20220505 备注含按“规定账户规模调整”字样的就不校验单位划账户比例大于单位缴费比例
                    if (!aae013.contains("按规定账户规模调整") && 0 < informationDetail.getAaa043().compareTo(informationDetail.getAaa042())) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条单位缴费划入个人账户比例应小于等于单位缴费比例");
                    }
                }

            }
            /*校验个人缴费比例*/
            if (!(aae013.contains("定额缴费") || aae013.contains("曾办理异地转入")) && informationDetail.getAae202().intValue() > 0) {
                if (!ValidateUtil.isEmpty(aac032) && informationDetail.getAae041().intValue() >= aac032.intValue()) {

                    if (ValidateUtil.isEmpty(informationDetail.getAaa041())) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条除备注含“定额缴费”或“曾办理异地转入”字样的记录外，若缴费月数>0，个人缴费比例必须有值");
                    }
                }
            }
            if (!ValidateUtil.isEmpty(informationDetail.getAaa041())) {
                if (!aae013.contains("定额缴费") && !aae013.contains("曾办理异地转入")) {
                    if (1 > informationDetail.getAaa041().compareTo(BigDecimal.ZERO) || informationDetail.getAaa041().compareTo(BigDecimal.ONE) > -1) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条个人缴费比例应该在0-1之间");
                    }
                } else {
                    if (aae013.contains("定额缴费")) {
                        if (1 > informationDetail.getAaa041().compareTo(BigDecimal.ZERO) || informationDetail.getAaa041().compareTo(new BigDecimal(100)) > -1) {
                            throw new IllegalArgumentException("缴费明细中第" + i + "条定额缴费应在0-100之间");
                        }
                    }
                    if (aae013.contains("曾办理异地转入")) {
                        if (1 > informationDetail.getAaa041().compareTo(BigDecimal.ZERO)) {
                            throw new IllegalArgumentException("缴费明细中第" + i + "条曾办理异地缴费金额应该大于0");
                        }
                    }
                }
                if (informationDetail.getAae001().intValue() > 1997 && informationDetail.getAae001().intValue() < 2006 && informationDetail.getAae041().intValue() / 100 > 1997 && informationDetail.getAae042().intValue() / 100 < 2006) {
                    if (aaa041.add(aaa043).compareTo(new BigDecimal("0.11")) < 0) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条缴费起止时间为1998年1月至2005年12月的记录，个人缴费比例+单位缴费划入个人账户比例应≥11%");
                    }
                }
                if (informationDetail.getAae001().intValue() > 2005 && informationDetail.getAae041().intValue() / 100 > 2005) {
                    if (aaa041.add(aaa043).compareTo(new BigDecimal("0.08")) < 0) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条缴费起始时间为2006年1月及以后的记录，个人缴费比例+单位缴费划入个人账户比例应≥8%");
                    }
                }
            }

            /*校验当年记账金额*/
            if (ValidateUtil.isEmpty(informationMyMap.getAac032()) || informationDetail.getAae001().intValue() < Integer.valueOf(informationMyMap.getAac032().toString().substring(0, 4))) {
                if (!ValidateUtil.isEmpty(informationDetail.getAae381())) {
                    throw new IllegalArgumentException("缴费明细中第" + i + "条本人建立个人账户时间为空或者年份早于本人建立个人账户时间的记录，当年记账金额必须为空");
                }
            }
            if (!aae013.contains("曾办理异地转入") && !ValidateUtil.isEmpty(informationDetail.getAae382())) {
                if (ValidateUtil.isEmpty(informationDetail.getAae381())) {
                    throw new IllegalArgumentException("缴费明细中第" + i + "条除备注含“曾办理异地转入”字样的记录外，至本年末账户累计储存额有值时，当年记账金额必须有值");
                }
            }
            if (6 == informationDetail.getAae001().toString().length() && ValidateUtil.isEmpty(informationDetail.getAae381())) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条调转当年发生补缴的记录（即年份为YYYYMM格式的记录），当年记账金额必须有值");
            }
            if (!ValidateUtil.isEmpty(informationMyMap.getAac032()) && informationDetail.getAae001().intValue() >= Integer.valueOf(informationMyMap.getAac032().toString().substring(0, 4)) && year > informationDetail.getAae001().intValue()) {

                if (!ValidateUtil.isEmpty(informationDetail.getAae381())) {
                    if (informationDetail.getAae381().compareTo(BigDecimal.ZERO) > 0) {
                        if (ValidateUtil.isEmpty(informationDetail.getAae269()) || informationDetail.getAae269().compareTo(BigDecimal.ZERO) < 1
                                || ValidateUtil.isEmpty(informationDetail.getAae382()) || informationDetail.getAae382().compareTo(BigDecimal.ZERO) < 1) {
                            if (!ValidateUtil.isEmpty(informationDetail.getAae013()) && !informationDetail.getAae013().contains("退役军人")) {
                                throw new IllegalArgumentException("缴费明细中第" + i + "条年份为本人建立个人账户时间（有值时）至调转上年间的记录，如果当年记账金额>0，则当年记账利息>0，至本年末账户累计储存额>0");
                            }
                        }
                    }
                }

            }
            if (!ValidateUtil.isEmpty(informationMyMap.getAac032()) && informationDetail.getAae001().intValue() >= Integer.valueOf(informationMyMap.getAac032().toString().substring(0, 4)) && year >= informationDetail.getAae001().intValue()) {
                if (!ValidateUtil.isEmpty(informationDetail.getAae381())) {
                    if (informationDetail.getAae202().intValue() > 0 && !ValidateUtil.isEmpty(informationDetail.getAae381()) && informationDetail.getAae381().compareTo(BigDecimal.ZERO) < 1) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条年份为本人建立个人账户时间（有值时）至调转当年间的记录，如果当年记账金额有值：缴费月数不为0时，当年记账金额应>0");
                    }
                    if (informationDetail.getAae202().intValue() == 0 && !ValidateUtil.isEmpty(informationDetail.getAae381()) && informationDetail.getAae381().compareTo(BigDecimal.ZERO) < 0) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条年份为本人建立个人账户时间（有值时）至调转当年间的记录，如果当年记账金额有值:缴费月数为0时，当年记账金额应≥0");
                    }
                }
            }
            /*校验当年记账金额中的个人缴费部分*/
            if (ValidateUtil.isEmpty(informationMyMap.getAac032()) || informationDetail.getAae001().intValue() < Integer.valueOf(informationMyMap.getAac032().toString().substring(0, 4))) {
                if (!ValidateUtil.isEmpty(informationDetail.getAae264())) {
                    throw new IllegalArgumentException("缴费明细中第" + i + "条本人建立个人账户时间为空或者年份早于本人建立个人账户时间的记录，当年记账金额中的个人缴费部分必须为空");
                }
            }
            if (!aae013.contains("曾办理异地转入") && !ValidateUtil.isEmpty(informationDetail.getAae381())) {
                if (ValidateUtil.isEmpty(informationDetail.getAae264())) {
                    throw new IllegalArgumentException("缴费明细中第" + i + "条除备注含“曾办理异地转入”字样的记录外，当年记账金额有值时，当年记账金额中的个人缴费部分必须有值");
                }
            }
            if (6 == informationDetail.getAae001().toString().length() && ValidateUtil.isEmpty(informationDetail.getAae264())) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条调转当年发生补缴的记录（即年份为YYYYMM格式的记录），当年记账金额中的个人缴费部分必须有值");
            }
            if (!ValidateUtil.isEmpty(informationMyMap.getAac032()) && informationDetail.getAae001().intValue() >= Integer.valueOf(informationMyMap.getAac032().toString().substring(0, 4)) && year >= informationDetail.getAae001().intValue()) {
                if (!ValidateUtil.isEmpty(informationDetail.getAae264())) {
                    if (informationDetail.getAae202().intValue() > 0 && informationDetail.getAae264().compareTo(BigDecimal.ZERO) < 1) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条年份为本人建立个人账户时间（有值时）至调转当年间的记录，如果当年记账金额中的个人缴费部分有值：缴费月数不为0时，当年记账金额中的个人缴费部分应>0");
                    }
                    if (informationDetail.getAae202().intValue() == 0 && informationDetail.getAae264().compareTo(BigDecimal.ZERO) < 0) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条年份为本人建立个人账户时间（有值时）至调转当年间的记录，如果当年记账金额中的个人缴费部分有值：缴费月数为0时，当年记账金额中的个人缴费部分应≥0");
                    }
                }
            }
            if (!ValidateUtil.isEmpty(informationDetail.getAae264()) && informationDetail.getAae264().compareTo(aae381) > 0) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条当年记账金额中的个人缴费部分应≤当年记账金额");
            }
            /*校验当年记账利息*/
            if (ValidateUtil.isEmpty(informationMyMap.getAac032()) || informationDetail.getAae001().intValue() < Integer.valueOf(informationMyMap.getAac032().toString().substring(0, 4))) {
                if (!ValidateUtil.isEmpty(informationDetail.getAae269())) {
                    throw new IllegalArgumentException("缴费明细中第" + i + "条本人建立个人账户时间为空或者年份早于本人建立个人账户时间的记录，当年记账利息必须为空");
                }
            }
            if (!aae013.contains("曾办理异地转入") && !ValidateUtil.isEmpty(informationDetail.getAae382())) {
                if (ValidateUtil.isEmpty(informationDetail.getAae269())) {
                    throw new IllegalArgumentException("缴费明细中第" + i + "条除备注含“曾办理异地转入”字样的记录外，至本年末账户累计储存额有值时，当年记账利息必须有值");
                }
            }
            if (!ValidateUtil.isEmpty(informationMyMap.getAac032()) && informationDetail.getAae001().intValue() >= Integer.valueOf(informationMyMap.getAac032().toString().substring(0, 4)) && year > informationDetail.getAae001().intValue()) {
                if (!ValidateUtil.isEmpty(informationDetail.getAae269()) && informationDetail.getAae269().compareTo(BigDecimal.ZERO) > 0) {
                    if (aae381.compareTo(BigDecimal.ZERO) < 1 || aae382.compareTo(BigDecimal.ZERO) < 1) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条年份为本人建立个人账户时间（有值时）至调转上年间的记录，如果当年记账利息>0，则当年记账金额>0，至本年末账户累计储存额>0");
                    }
                }
                if (!ValidateUtil.isEmpty(informationDetail.getAae269())) {
                    if (informationDetail.getAae202().intValue() > 0 && informationDetail.getAae269().compareTo(BigDecimal.ZERO) < 1) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条年份为本人建立个人账户时间（有值时）至调转上年间的记录，如果当年记账利息有值：缴费月数不为0时，当年记账利息>0");
                    }
                    if (informationDetail.getAae202().intValue() == 0 && informationDetail.getAae269().compareTo(BigDecimal.ZERO) < 0) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条年份为本人建立个人账户时间（有值时）至调转上年间的记录，如果当年记账利息有值：缴费月数为0时，当年记账利息≥0");
                    }
                }
            }
            /*校验当年记账利息中的个人缴费部分*/
            if (ValidateUtil.isEmpty(informationMyMap.getAac032()) || informationDetail.getAae001().intValue() < Integer.valueOf(informationMyMap.getAac032().toString().substring(0, 4))) {
                if (!ValidateUtil.isEmpty(informationDetail.getAae265())) {
                    throw new IllegalArgumentException("缴费明细中第" + i + "条本人建立个人账户时间为空或者年份早于本人建立个人账户时间的记录，当年记账利息中的个人缴费部分必须为空");
                }
            }
            if (!aae013.contains("曾办理异地转入") && !ValidateUtil.isEmpty(informationDetail.getAae269())) {
                if (ValidateUtil.isEmpty(informationDetail.getAae265())) {
                    throw new IllegalArgumentException("缴费明细中第" + i + "条除备注含“曾办理异地转入”字样的记录外，当年记账利息有值时，当年记账利息中的个人缴费部分必须有值");
                }
            }
            if (!ValidateUtil.isEmpty(informationMyMap.getAac032()) && informationDetail.getAae001().intValue() >= Integer.valueOf(informationMyMap.getAac032().toString().substring(0, 4)) && year > informationDetail.getAae001().intValue()) {
                if (!ValidateUtil.isEmpty(informationDetail.getAae265())) {
                    if (informationDetail.getAae202().intValue() > 0 && informationDetail.getAae265().compareTo(BigDecimal.ZERO) < 1) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条年份为本人建立个人账户时间（有值时）至调转上年间的记录，如果当年记账利息中的个人缴费部分有值：缴费月数不为0时，当年记账利息中的个人缴费部分>0；");
                    }
                    if (informationDetail.getAae202().intValue() == 0 && informationDetail.getAae265().compareTo(BigDecimal.ZERO) < 0) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条年份为本人建立个人账户时间（有值时）至调转上年间的记录，如果当年记账利息中的个人缴费部分有值：缴费月数为0时，当年记账利息中的个人缴费部分≥0");
                    }
                }
            }
            if (!ValidateUtil.isEmpty(informationDetail.getAae265()) && informationDetail.getAae265().compareTo(aae269) > 0) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条当年记账利息中的个人缴费部分应≤当年记账利息");
            }
            /*校验至本年末账户累计储存额*/
            // 调转当年存在补缴写YYYYMM格式需要截取
            if (Integer.valueOf(informationDetail.getAae001().toString().substring(0, 4)).equals(year) && !ValidateUtil.isEmpty(informationDetail.getAae382())) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条调转当年的记录，至本年末账户累计储存额必须为空");
            }
            /*校验至本年末账户累计储存额中的个人缴费部分*/
            if (Integer.valueOf(informationDetail.getAae001().toString().substring(0, 4)).equals(year) && !ValidateUtil.isEmpty(informationDetail.getAae273())) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条调转当年的记录，至本年末账户累计储存额中的个人缴费部分必须为空");
            }
            if (!ValidateUtil.isEmpty(informationDetail.getAae382()) && ValidateUtil.isEmpty(informationDetail.getAae273())) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条至本年末账户累计储存额有值时，至本年末账户累计储存额中的个人缴费部分必须有值");
            }
            if (!ValidateUtil.isEmpty(informationDetail.getAae273()) && informationDetail.getAae273().compareTo(aae382) > 0) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条如果有值，至本年末账户累计储存额中的个人缴费部分应≤至本年末账户累计储存额");
            }
            /*校验备注*/
            if (informationDetail.getAae001().intValue() > 1997 && aae013.contains("定额缴费")) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条缴费起始时间在1998年1月及以后的记录，备注中不能含“定额缴费”字样");
            }
            if (informationDetail.getAae001().intValue() > 2009 && aae013.contains("曾办理异地转入")) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条缴费起始时间在2010年1月及以后的记录，备注中不能含“曾办理异地转入”字样");
            }
            if (informationDetail.getAae001().intValue() < 2010 && aae013.contains("临时缴费账户")) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条缴费起始时间在2010年1月之前的记录，备注中不能含“临时缴费账户”字样");
            }

            if (aae382.compareTo(BigDecimal.ZERO) > 0 && informationDetail.getAae001().intValue() < year) {
                flag = true;
            }


//            if (!aaa102s.contains(informationDetail.getAab301())) {
//                throw new IllegalArgumentException("缴费明细中第" + i + "条转出地行政区划"+informationDetail.getAab301()+"不在中台码表范围内，请核实");
//            }
//            if (!aaa102s.contains(informationDetail.getAab299())) {
//                throw new IllegalArgumentException("缴费明细中第" + i + "条参保地行政区划"+informationDetail.getAab299()+"不在中台码表范围内，请核实");
//            }


            informationDetailMyMaps.add(MyMap.convertToMap(informationDetail));
            i++;
        }
        // 缴费记录按照结束期号排序
        //Collections.sort(informationDetailMyMaps, Comparator.comparing(a -> Integer.valueOf(a.get("aae042") + "")));
        /*校验当年记账金额*/
        // 1998-2005年之间的缴费记录
        List<MyMap> informationDetail1998TO2005 = informationDetailMyMaps.stream().filter(m -> m.getAsInteger("aae001") > 1997 && 2006 > m.getAsInteger("aae001")).collect(Collectors.toList());
        BigDecimal tmpTotal;
        for (MyMap myMap : informationDetail1998TO2005) {
            tmpTotal = BigDecimal.ZERO;
            if (myMap.getAsInteger("aae041").intValue() / 100 > 1997 && myMap.getAsInteger("aae042").intValue() / 100 < 2006) {
                aae180 = nullToBigdecimalZero((myMap.getAsBigDecimal("aae180")));
                aae202 = BigDecimalUtil.getBigDecimal(myMap.getAsInteger("aae042") - myMap.getAsInteger("aae041") + 1);

                tmpTotal = tmpTotal.add(aae180.multiply(aae202).multiply(new BigDecimal("0.11")));
                if (!ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae381"))) {
                    if (myMap.getAsBigDecimal("aae381").add(BigDecimal.ONE).compareTo(tmpTotal) < 0) {
                        throw new IllegalArgumentException(myMap.getAsString("aae001") + "年错误,【1998年至2005年的记录（不包括该期间补缴1998年前的记录），（当年记账金额+1）应≥∑月缴费基数×缴费月数×11%】");
                    }
//                    else {
//                        tmpTotal = BigDecimal.ZERO;
//                    }
                }
            }

        }
        List<MyMap> informationDetail2005TOYearBefore = informationDetailMyMaps.stream().filter(m -> m.getAsInteger("aae001") > 2005 /*&& year > m.getAsInteger("aae001")*/).collect(Collectors.toList());

        for (MyMap myMap : informationDetail2005TOYearBefore) {
            tmpTotal = BigDecimal.ZERO;
            if (myMap.getAsInteger("aae041").intValue() / 100 > 2005) {
                aae180 = nullToBigdecimalZero((myMap.getAsBigDecimal("aae180")));
                aae202 = BigDecimalUtil.getBigDecimal(myMap.getAsInteger("aae042") - myMap.getAsInteger("aae041") + 1);
                tmpTotal = tmpTotal.add((aae180).multiply(aae202).multiply(new BigDecimal("0.08")));
                if (!ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae381")) && myMap.getAsBigDecimal("aae381").compareTo(BigDecimal.ZERO) > 0) {
                    if (myMap.getAsBigDecimal("aae381").add(BigDecimal.ONE).compareTo(tmpTotal) < 0) {
                        throw new IllegalArgumentException(myMap.getAsString("aae001") + "年错误,【2006年至调转上年的记录（不包括该期间补缴2006年前的记录），（当年记账金额+1）应≥∑月缴费基数×缴费月数×8%】");
                    }/* else {
                        //tmpTotal = BigDecimal.ZERO;
                    }*/
                }
            }

        }

        List<MyMap> informationDetailYearBefore = informationDetailMyMaps.stream().filter(m -> year > m.getAsInteger("aae001")).collect(Collectors.toList());
        if (!ValidateUtil.isEmpty(informationMyMap.getAic083())) {
            if (!ValidateUtil.isEmpty(informationDetailYearBefore)) {
                MyMap myMap = informationDetailYearBefore.get(informationDetailYearBefore.size() - 1);
                /*校验至本年末账户累计储存额*/
                if (ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae382"))) {
                    throw new IllegalArgumentException("如果个人账户基金转移额>0，调转当年之前如果有记录，则调转上年12月所在记录的至本年末账户累计储存额必须有值");
                }
                /*校验至本年末账户累计储存额中的个人缴费部分*/
                if (ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae273"))) {
                    throw new IllegalArgumentException("调转当年之前如果有记录，则调转上年12月所在记录的至本年末账户累计储存额中的个人缴费部分必须有值");
                }
            }
        }

        if (flag) {
            for (MyMap myMap : informationDetailMyMaps) {
                //调转上年末是否有12月台帐
                if (!ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae382")) && myMap.getAsBigDecimal("aae382").compareTo(BigDecimal.ZERO) > 0
                        && myMap.getAsInteger("aae001") == year - 1 && "12".equals(myMap.getAsInteger("aae042").toString().substring(4))) {
                    flag = false;
                    break;
                }
            }
        }

        if (flag) {
            throw new IllegalArgumentException("如果调转当年之前如果有台帐记录，则调转上年12月所在记录的至本年末账户累计储存额必须有值");
        }


        BigDecimal tmpAae382 = BigDecimal.ZERO;
        BigDecimal tmpAae273 = BigDecimal.ZERO;
        BigDecimal tmpAae381 = BigDecimal.ZERO;

        BigDecimal tmpAae264 = BigDecimal.ZERO;

        BigDecimal tmpAae269 = BigDecimal.ZERO;

        BigDecimal tmpAae265 = BigDecimal.ZERO;

        for (int j = 0; j < informationDetailMyMaps.size(); j++) {

            MyMap myMap = informationDetailMyMaps.get(j);

            tmpAae381 = ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae381")) ? BigDecimal.ZERO : myMap.getAsBigDecimal("aae381");
            tmpAae269 = ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae269")) ? BigDecimal.ZERO : myMap.getAsBigDecimal("aae269");
            tmpAae264 = ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae264")) ? BigDecimal.ZERO : myMap.getAsBigDecimal("aae264");
            tmpAae265 = ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae265")) ? BigDecimal.ZERO : myMap.getAsBigDecimal("aae265");

            if (tmpAae382.compareTo(BigDecimal.ZERO) > 0) {
                /*校验至本年末账户累计储存额*/
                if (!ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae382"))) {
                    if (myMap.getAsBigDecimal("aae382").compareTo(tmpAae382.add(tmpAae381).add(tmpAae269)) < 0) {
                        throw new IllegalArgumentException("第" + (j + 1) + "条至本年末账户累计储存额应≥至上年末账户累计储存额+当年记账金额+当年记账利息");
                    }
                    //tmpAae382 = myMap.getAsBigDecimal("aae382");
                }
                /*校验至本年末账户累计储存额中的个人缴费部分*/
                if (!ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae273"))) {
                    if (myMap.getAsBigDecimal("aae273").compareTo(tmpAae273.add(tmpAae264).add(tmpAae265)) < 0) {
                        throw new IllegalArgumentException("第" + (j + 1) + "条至本年末账户累计储存额中的个人缴费部分应≥至上年末账户累计储存额中的个人缴费部分+当年记账金额中的个人缴费部分+当年记账利息中的个人缴费部分");
                    }
                    //tmpAae273 = myMap.getAsBigDecimal("aae273");
                }
            }

            tmpAae382 = ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae382")) ? BigDecimal.ZERO : myMap.getAsBigDecimal("aae382");
            tmpAae273 = ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae273")) ? BigDecimal.ZERO : myMap.getAsBigDecimal("aae273");
            /*tmpAae381 = ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae381")) ? BigDecimal.ZERO : myMap.getAsBigDecimal("aae381");
            tmpAae269 = ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae269")) ? BigDecimal.ZERO : myMap.getAsBigDecimal("aae269");
            tmpAae264 = ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae264")) ? BigDecimal.ZERO : myMap.getAsBigDecimal("aae264");
            tmpAae265 = ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae265")) ? BigDecimal.ZERO : myMap.getAsBigDecimal("aae265");*/

        }
        /*校验至本年末账户累计储存额*/
        // 校验连续记录最后一条含aae382
        for (int j = 0; j < informationDetailMyMaps.size(); j++) {

            if (informationDetailMyMaps.get(j).getAsString("aae013").contains("曾办理异地转入")) {
                if (!ValidateUtil.isEmpty(informationMyMap.getAac032())) {
                    if (informationDetailMyMaps.get(j).getAsInteger("aae001") > informationMyMap.getAac032().intValue() / 100) {
                        if (j + 1 < informationDetailMyMaps.size() && !(informationDetailMyMaps.get(j + 1).getAsString("aae013").contains("曾办理异地转入"))
                                && ValidateUtil.isEmpty(informationDetailMyMaps.get(j).getAsBigDecimal("aae382"))) {
                            throw new IllegalArgumentException("备注含“曾办理异地转入”字样的连续记录的最后一条，至本年末账户累计储存额必须有值");
                        }
                    }
                    if (j == informationDetailMyMaps.size() - 1 && ValidateUtil.isEmpty(informationDetailMyMaps.get(j).getAsBigDecimal("aae382"))) {
                        throw new IllegalArgumentException("备注含“曾办理异地转入”字样的连续记录的最后一条，至本年末账户累计储存额必须有值");
                    }
                }

            }

        }
    }

    /**
     * 城职信息表明细校验
     *
     * @param informationInfo    信息表
     * @param informationDetails 信息表明细
     */
    @Override
    public void checkInformationOfOfficeDetails(InformationInfo informationInfo, List<InformationDetailInfo> informationDetails) {
        Ic66Info informationMyMap = (Ic66Info) informationInfo;

        Ic67Info informationDetail;
        // 获取调转本年
        Integer year = DateUtil.getYear(DateUtil.stringToDate(informationMyMap.getAae035().toString(), "yyyyMMdd", false));
        List<MyMap> informationDetailMyMaps = new ArrayList<>();
        int i = 1;


        BigDecimal aaa043;
        BigDecimal aaa041;
        BigDecimal aae180;
        BigDecimal aae202;
        BigDecimal aae269;
        BigDecimal aae381;
        BigDecimal aae382;
        String aae013;

        boolean flag = false;

        BigDecimal aae381_cal = BigDecimal.ZERO;//当年记账金额
        //BigDecimal aae264_cal = BigDecimal.ZERO;//当年记账金额中的个人缴费部分

        Integer aac032 = null;
        if (!ValidateUtil.isEmpty(informationMyMap.getAac032())) {
            aac032 = informationMyMap.getAac032().intValue();
        }
        for (InformationDetailInfo detailInfo : informationDetails) {
            informationDetail = (Ic67Info) detailInfo;

            aaa043 = ValidateUtil.isEmpty(informationDetail.getAaa043()) ? BigDecimal.ZERO : informationDetail.getAaa043();
            aaa041 = ValidateUtil.isEmpty(informationDetail.getAaa041()) ? BigDecimal.ZERO : informationDetail.getAaa041();
            aae180 = ValidateUtil.isEmpty(informationDetail.getAae180()) ? BigDecimal.ZERO : informationDetail.getAae180();
            aae269 = ValidateUtil.isEmpty(informationDetail.getAae269()) ? BigDecimal.ZERO : informationDetail.getAae269();
            aae381 = ValidateUtil.isEmpty(informationDetail.getAae381()) ? BigDecimal.ZERO : informationDetail.getAae381();
            aae382 = ValidateUtil.isEmpty(informationDetail.getAae382()) ? BigDecimal.ZERO : informationDetail.getAae382();
            aae202 = ValidateUtil.isEmpty(informationDetail.getAae202()) ? BigDecimal.ZERO : informationDetail.getAae202();
            aae013 = ValidateUtil.isEmpty(informationDetail.getAae013()) ? "" : informationDetail.getAae013();


            if (!ValidateUtil.isEmpty(aac032) && informationDetail.getAae041().intValue() >= aac032) {
                aae381_cal = aae381_cal.add(aae180.multiply(aae202).multiply(aaa043.add(aaa041)));
//                aae264_cal = aae264_cal.add(aae180.multiply(aae202).multiply(aaa041));
                if (aae382.compareTo(BigDecimal.ZERO) > 0) {
                    if (!"曾办理异地转入".equals(aae013)) {
                        if (aae381_cal.setScale(2, BigDecimal.ROUND_HALF_UP).compareTo(aae381.add(BigDecimal.ONE)) > 0) {
                            throw new IllegalArgumentException("缴费明细" + informationDetail.getAae001() + "年,当年记账金额应≥ 基数*比例*月数");
                        }
                    }
                }
                aae381_cal = BigDecimal.ZERO;
                //aae264_cal = BigDecimal.ZERO;
            }


            /*校验人员编号*/
            NPETool.isEmptyThrowException(informationDetail.getAac319(), "缴费明细中第" + i + "条人员编号");
            if (!informationMyMap.getAac319().equals(informationDetail.getAac319())) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条人员编号和信息表不一致");
            }
            /*校验转出地行政区划代码*/
            NPETool.isEmptyThrowException(informationDetail.getAab301(), "缴费明细中第" + i + "条转出地行政区划代码");
          /*  if (!informationMyMap.getAab301().equals(informationDetail.getAab301())) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条转出地行政区划代码和信息表不一致");
            }*/
            /*校验参保地行政区划代码*/
            NPETool.isEmptyThrowException(informationDetail.getAab299(), "缴费明细中第" + i + "条参保地行政区划代码");
            /*校验参保地名称*/
            NPETool.isEmptyThrowException(informationDetail.getAab300(), "缴费明细中第" + i + "条参保地名称");
            /*校验年份*/
            NPETool.isEmptyThrowException(informationDetail.getAae001(), "缴费明细中第" + i + "条年份");
            /*校验缴费起始时间  */
            NPETool.isEmptyThrowException(informationDetail.getAae041(), "缴费明细中第" + i + "条缴费起始时间");
            /*校验缴费结束始时间  */
            NPETool.isEmptyThrowException(informationDetail.getAae042(), "缴费明细中第" + i + "条缴费结束时间");
            /*校验缴费月数*/
            NPETool.isEmptyThrowException(informationDetail.getAae202(), "缴费明细中第" + i + "条缴费月数");
            if (4 != informationDetail.getAae001().toString().length() && 6 != informationDetail.getAae001().toString().length()) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条年限格式错误");
            }

            //因为转移当年如果存在基数调整，这个校验就无法通过
           /* if (6 == informationDetail.getAae001().toString().length() && Integer.valueOf(informationDetail.getAae001().toString().substring(0, 4)) == year) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条格式错误,年限格式为YYYYMM必须是调转当年的补缴记录");
            }*/
            /*校验缴费起始时间  结束始时间*/
            if (6 != informationDetail.getAae041().toString().length()) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条缴费起始时间格式错误");
            }
            if (informationDetail.getAae041().intValue() > DateUtil.toIssue(new Date())) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条缴费起始时间应小于等于当前系统时间");
            }
            if (informationDetail.getAae041().intValue() > informationDetail.getAae042().intValue()) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条缴费起始时间应小于等于缴费结束时间");
            }

            if (6 != informationDetail.getAae042().toString().length()) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条缴费结束始时间错误");
            }
            if (informationDetail.getAae042().intValue() > DateUtil.toIssue(new Date())) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条缴费结束始时间应小于等于当前系统时间");
            }
            if (!informationDetail.getAae041().toString().substring(0, 4).equals(informationDetail.getAae042().toString().substring(0, 4))) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条缴费起始时间和缴费结束时间应在同一年度");
            }
            /*校验缴费月数*/
            if (informationDetail.getAae202().intValue() != DateUtil.getBetweenCountIssue(informationDetail.getAae041().intValue(), informationDetail.getAae042().intValue()) && informationDetail.getAae202().intValue() != 0) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条缴费月数错误");
            }
            /*校验月缴费基数*/
            if ((informationDetail.getAae001().intValue() < 1998 && !aae013.contains("定额缴费"))
                    || informationDetail.getAae001().intValue() > 1997) {
                if (informationDetail.getAae202().intValue() > 0 && aae180.compareTo(BigDecimal.ZERO) < 1) {
                    throw new IllegalArgumentException("缴费明细中第" + i + "条缴费终止时间为1998年1月之前且备注不包含“定额缴费”字样的记录中，以及缴费起始时间为1998年1月及以后的记录中，若缴费月数>0，则月缴费基数>0");
                }
            }
            if (informationDetail.getAae001().intValue() < 1998 && aae013.contains("定额缴费")) {
                if (aae180.compareTo(BigDecimal.ZERO) < 1 && aaa041.compareTo(BigDecimal.ZERO) < 1) {
                    throw new IllegalArgumentException("缴费明细中第" + i + "条缴费终止时间为1998年1月之前且备注含“定额缴费”字样的记录，月缴费基数和个人缴费比例两项之一必须>0");
                }
            }
            /*校验单位缴费比例*/
            if (!(aae013.contains("定额缴费") || aae013.contains("曾办理异地转入")) && informationDetail.getAae202().intValue() > 0) {
                if (!ValidateUtil.isEmpty(aac032) && informationDetail.getAae041().intValue() >= aac032.intValue()) {
                    if (ValidateUtil.isEmpty(informationDetail.getAaa042())) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条除备注含“定额缴费”或“曾办理异地转入”字样的记录外，若缴费月数>0，单位缴费比例必须有值");
                    }
                }
            }

            if (!ValidateUtil.isEmpty(informationDetail.getAaa042())) {
                if (1 > informationDetail.getAaa042().compareTo(BigDecimal.ZERO) || informationDetail.getAaa042().compareTo(BigDecimal.ONE) > -1) {
                    throw new IllegalArgumentException("缴费明细中第" + i + "条单位缴费比例应该大于0小于1");
                }
            }
            /*校验单位缴费划入个人账户比例*/
            if (!ValidateUtil.isEmpty(informationDetail.getAaa043())) {
                if (0 > informationDetail.getAaa043().compareTo(BigDecimal.ZERO) || informationDetail.getAaa043().compareTo(BigDecimal.ONE) > -1) {
                    throw new IllegalArgumentException("缴费明细中第" + i + "条单位缴费划入个人账户比例应该在0-1之间");
                }
                if (!ValidateUtil.isEmpty(informationDetail.getAaa042())) {
                    //20220505 备注含按“规定账户规模调整”字样的就不校验单位划账户比例大于单位缴费比例
                    if (!aae013.contains("按规定账户规模调整") && 0 < informationDetail.getAaa043().compareTo(informationDetail.getAaa042())) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条单位缴费划入个人账户比例应小于等于单位缴费比例");
                    }
                }

            }
            /*校验个人缴费比例*/
            if (!(aae013.contains("定额缴费") || aae013.contains("曾办理异地转入")) && informationDetail.getAae202().intValue() > 0) {
                if (!ValidateUtil.isEmpty(aac032) && informationDetail.getAae041().intValue() >= aac032.intValue()) {

                    if (ValidateUtil.isEmpty(informationDetail.getAaa041())) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条除备注含“定额缴费”或“曾办理异地转入”字样的记录外，若缴费月数>0，个人缴费比例必须有值");
                    }
                }
            }
            if (!ValidateUtil.isEmpty(informationDetail.getAaa041())) {
                if (!aae013.contains("定额缴费") && !aae013.contains("曾办理异地转入")) {
                    if (1 > informationDetail.getAaa041().compareTo(BigDecimal.ZERO) || informationDetail.getAaa041().compareTo(BigDecimal.ONE) > -1) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条个人缴费比例应该在0-1之间");
                    }
                } else {
                    if (aae013.contains("定额缴费")) {
                        if (1 > informationDetail.getAaa041().compareTo(BigDecimal.ZERO) || informationDetail.getAaa041().compareTo(new BigDecimal(100)) > -1) {
                            throw new IllegalArgumentException("缴费明细中第" + i + "条定额缴费应在0-100之间");
                        }
                    }
                    if (aae013.contains("曾办理异地转入")) {
                        if (1 > informationDetail.getAaa041().compareTo(BigDecimal.ZERO)) {
                            throw new IllegalArgumentException("缴费明细中第" + i + "条曾办理异地缴费金额应该大于0");
                        }
                    }
                }
                if (informationDetail.getAae001().intValue() > 1997 && informationDetail.getAae001().intValue() < 2006 && informationDetail.getAae041().intValue() / 100 > 1997 && informationDetail.getAae042().intValue() / 100 < 2006) {
                    if (aaa041.add(aaa043).compareTo(new BigDecimal("0.11")) < 0) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条缴费起止时间为1998年1月至2005年12月的记录，个人缴费比例+单位缴费划入个人账户比例应≥11%");
                    }
                }
                if (informationDetail.getAae001().intValue() > 2005 && informationDetail.getAae041().intValue() / 100 > 2005) {
                    if (aaa041.add(aaa043).compareTo(new BigDecimal("0.08")) < 0) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条缴费起始时间为2006年1月及以后的记录，个人缴费比例+单位缴费划入个人账户比例应≥8%");
                    }
                }
            }

            /*校验当年记账金额*/
            if (ValidateUtil.isEmpty(informationMyMap.getAac032()) || informationDetail.getAae001().intValue() < Integer.valueOf(informationMyMap.getAac032().toString().substring(0, 4))) {
                if (!ValidateUtil.isEmpty(informationDetail.getAae381())) {
                    throw new IllegalArgumentException("缴费明细中第" + i + "条本人建立个人账户时间为空或者年份早于本人建立个人账户时间的记录，当年记账金额必须为空");
                }
            }
            if (!aae013.contains("曾办理异地转入") && !ValidateUtil.isEmpty(informationDetail.getAae382())) {
                if (ValidateUtil.isEmpty(informationDetail.getAae381())) {
                    throw new IllegalArgumentException("缴费明细中第" + i + "条除备注含“曾办理异地转入”字样的记录外，至本年末账户累计储存额有值时，当年记账金额必须有值");
                }
            }
            if (6 == informationDetail.getAae001().toString().length() && ValidateUtil.isEmpty(informationDetail.getAae381())) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条调转当年发生补缴的记录（即年份为YYYYMM格式的记录），当年记账金额必须有值");
            }
            if (!ValidateUtil.isEmpty(informationMyMap.getAac032()) && informationDetail.getAae001().intValue() >= Integer.valueOf(informationMyMap.getAac032().toString().substring(0, 4)) && year > informationDetail.getAae001().intValue()) {

                if (!ValidateUtil.isEmpty(informationDetail.getAae381())) {
                    if (informationDetail.getAae381().compareTo(BigDecimal.ZERO) > 0) {
                        if (ValidateUtil.isEmpty(informationDetail.getAae269()) || informationDetail.getAae269().compareTo(BigDecimal.ZERO) < 1
                                || ValidateUtil.isEmpty(informationDetail.getAae382()) || informationDetail.getAae382().compareTo(BigDecimal.ZERO) < 1) {
                            if (!ValidateUtil.isEmpty(informationDetail.getAae013()) && !informationDetail.getAae013().contains("退役军人")) {
                                throw new IllegalArgumentException("缴费明细中第" + i + "条年份为本人建立个人账户时间（有值时）至调转上年间的记录，如果当年记账金额>0，则当年记账利息>0，至本年末账户累计储存额>0");
                            }
                        }
                    }
                }

            }
            if (!ValidateUtil.isEmpty(informationMyMap.getAac032()) && informationDetail.getAae001().intValue() >= Integer.valueOf(informationMyMap.getAac032().toString().substring(0, 4)) && year >= informationDetail.getAae001().intValue()) {
                if (!ValidateUtil.isEmpty(informationDetail.getAae381())) {
                    if (informationDetail.getAae202().intValue() > 0 && !ValidateUtil.isEmpty(informationDetail.getAae381()) && informationDetail.getAae381().compareTo(BigDecimal.ZERO) < 1) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条年份为本人建立个人账户时间（有值时）至调转当年间的记录，如果当年记账金额有值：缴费月数不为0时，当年记账金额应>0");
                    }
                    if (informationDetail.getAae202().intValue() == 0 && !ValidateUtil.isEmpty(informationDetail.getAae381()) && informationDetail.getAae381().compareTo(BigDecimal.ZERO) < 0) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条年份为本人建立个人账户时间（有值时）至调转当年间的记录，如果当年记账金额有值:缴费月数为0时，当年记账金额应≥0");
                    }
                }
            }
            /*校验当年记账金额中的个人缴费部分*/
            if (ValidateUtil.isEmpty(informationMyMap.getAac032()) || informationDetail.getAae001().intValue() < Integer.valueOf(informationMyMap.getAac032().toString().substring(0, 4))) {
                if (!ValidateUtil.isEmpty(informationDetail.getAae264())) {
                    throw new IllegalArgumentException("缴费明细中第" + i + "条本人建立个人账户时间为空或者年份早于本人建立个人账户时间的记录，当年记账金额中的个人缴费部分必须为空");
                }
            }
            if (!aae013.contains("曾办理异地转入") && !ValidateUtil.isEmpty(informationDetail.getAae381())) {
                if (ValidateUtil.isEmpty(informationDetail.getAae264())) {
                    throw new IllegalArgumentException("缴费明细中第" + i + "条除备注含“曾办理异地转入”字样的记录外，当年记账金额有值时，当年记账金额中的个人缴费部分必须有值");
                }
            }
            if (6 == informationDetail.getAae001().toString().length() && ValidateUtil.isEmpty(informationDetail.getAae264())) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条调转当年发生补缴的记录（即年份为YYYYMM格式的记录），当年记账金额中的个人缴费部分必须有值");
            }
            if (!ValidateUtil.isEmpty(informationMyMap.getAac032()) && informationDetail.getAae001().intValue() >= Integer.valueOf(informationMyMap.getAac032().toString().substring(0, 4)) && year >= informationDetail.getAae001().intValue()) {
                if (!ValidateUtil.isEmpty(informationDetail.getAae264())) {
                    if (informationDetail.getAae202().intValue() > 0 && informationDetail.getAae264().compareTo(BigDecimal.ZERO) < 1) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条年份为本人建立个人账户时间（有值时）至调转当年间的记录，如果当年记账金额中的个人缴费部分有值：缴费月数不为0时，当年记账金额中的个人缴费部分应>0");
                    }
                    if (informationDetail.getAae202().intValue() == 0 && informationDetail.getAae264().compareTo(BigDecimal.ZERO) < 0) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条年份为本人建立个人账户时间（有值时）至调转当年间的记录，如果当年记账金额中的个人缴费部分有值：缴费月数为0时，当年记账金额中的个人缴费部分应≥0");
                    }
                }
            }
            if (!ValidateUtil.isEmpty(informationDetail.getAae264()) && informationDetail.getAae264().compareTo(aae381) > 0) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条当年记账金额中的个人缴费部分应≤当年记账金额");
            }
            /*校验当年记账利息*/
            if (ValidateUtil.isEmpty(informationMyMap.getAac032()) || informationDetail.getAae001().intValue() < Integer.valueOf(informationMyMap.getAac032().toString().substring(0, 4))) {
                if (!ValidateUtil.isEmpty(informationDetail.getAae269())) {
                    throw new IllegalArgumentException("缴费明细中第" + i + "条本人建立个人账户时间为空或者年份早于本人建立个人账户时间的记录，当年记账利息必须为空");
                }
            }
            if (!aae013.contains("曾办理异地转入") && !ValidateUtil.isEmpty(informationDetail.getAae382())) {
                if (ValidateUtil.isEmpty(informationDetail.getAae269())) {
                    throw new IllegalArgumentException("缴费明细中第" + i + "条除备注含“曾办理异地转入”字样的记录外，至本年末账户累计储存额有值时，当年记账利息必须有值");
                }
            }
            if (!ValidateUtil.isEmpty(informationMyMap.getAac032()) && informationDetail.getAae001().intValue() >= Integer.valueOf(informationMyMap.getAac032().toString().substring(0, 4)) && year > informationDetail.getAae001().intValue()) {
                if (!ValidateUtil.isEmpty(informationDetail.getAae269()) && informationDetail.getAae269().compareTo(BigDecimal.ZERO) > 0) {
                    if (aae381.compareTo(BigDecimal.ZERO) < 1 || aae382.compareTo(BigDecimal.ZERO) < 1) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条年份为本人建立个人账户时间（有值时）至调转上年间的记录，如果当年记账利息>0，则当年记账金额>0，至本年末账户累计储存额>0");
                    }
                }
                if (!ValidateUtil.isEmpty(informationDetail.getAae269())) {
                    if (informationDetail.getAae202().intValue() > 0 && informationDetail.getAae269().compareTo(BigDecimal.ZERO) < 1) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条年份为本人建立个人账户时间（有值时）至调转上年间的记录，如果当年记账利息有值：缴费月数不为0时，当年记账利息>0");
                    }
                    if (informationDetail.getAae202().intValue() == 0 && informationDetail.getAae269().compareTo(BigDecimal.ZERO) < 0) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条年份为本人建立个人账户时间（有值时）至调转上年间的记录，如果当年记账利息有值：缴费月数为0时，当年记账利息≥0");
                    }
                }
            }
            /*校验当年记账利息中的个人缴费部分*/
            if (ValidateUtil.isEmpty(informationMyMap.getAac032()) || informationDetail.getAae001().intValue() < Integer.valueOf(informationMyMap.getAac032().toString().substring(0, 4))) {
                if (!ValidateUtil.isEmpty(informationDetail.getAae265())) {
                    throw new IllegalArgumentException("缴费明细中第" + i + "条本人建立个人账户时间为空或者年份早于本人建立个人账户时间的记录，当年记账利息中的个人缴费部分必须为空");
                }
            }
            if (!aae013.contains("曾办理异地转入") && !ValidateUtil.isEmpty(informationDetail.getAae269())) {
                if (ValidateUtil.isEmpty(informationDetail.getAae265())) {
                    throw new IllegalArgumentException("缴费明细中第" + i + "条除备注含“曾办理异地转入”字样的记录外，当年记账利息有值时，当年记账利息中的个人缴费部分必须有值");
                }
            }

            if (!ValidateUtil.isEmpty(informationMyMap.getAac032()) && informationDetail.getAae001().intValue() >= Integer.valueOf(informationMyMap.getAac032().toString().substring(0, 4)) && year > informationDetail.getAae001().intValue()) {
                if (!ValidateUtil.isEmpty(informationDetail.getAae265())) {
                    if (informationDetail.getAae202().intValue() > 0 && informationDetail.getAae265().compareTo(BigDecimal.ZERO) < 1) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条年份为本人建立个人账户时间（有值时）至调转上年间的记录，如果当年记账利息中的个人缴费部分有值：缴费月数不为0时，当年记账利息中的个人缴费部分>0；");
                    }
                    if (informationDetail.getAae202().intValue() == 0 && informationDetail.getAae265().compareTo(BigDecimal.ZERO) < 0) {
                        throw new IllegalArgumentException("缴费明细中第" + i + "条年份为本人建立个人账户时间（有值时）至调转上年间的记录，如果当年记账利息中的个人缴费部分有值：缴费月数为0时，当年记账利息中的个人缴费部分≥0");
                    }
                }
            }

            if (!ValidateUtil.isEmpty(informationDetail.getAae265()) && informationDetail.getAae265().compareTo(aae269) > 0) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条当年记账利息中的个人缴费部分应≤当年记账利息");
            }
            /*校验至本年末账户累计储存额*/
            // 调转当年存在补缴写YYYYMM格式需要截取
            if (Integer.valueOf(informationDetail.getAae001().toString().substring(0, 4)).equals(year) && !ValidateUtil.isEmpty(informationDetail.getAae382())) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条调转当年的记录，至本年末账户累计储存额必须为空");
            }
            /*校验至本年末账户累计储存额中的个人缴费部分*/
            if (Integer.valueOf(informationDetail.getAae001().toString().substring(0, 4)).equals(year) && !ValidateUtil.isEmpty(informationDetail.getAae273())) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条调转当年的记录，至本年末账户累计储存额中的个人缴费部分必须为空");
            }
            if (!ValidateUtil.isEmpty(informationDetail.getAae382()) && ValidateUtil.isEmpty(informationDetail.getAae273())) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条至本年末账户累计储存额有值时，至本年末账户累计储存额中的个人缴费部分必须有值");
            }
            if (!ValidateUtil.isEmpty(informationDetail.getAae273()) && informationDetail.getAae273().compareTo(aae382) > 0) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条如果有值，至本年末账户累计储存额中的个人缴费部分应≤至本年末账户累计储存额");
            }
            /*校验备注*/
            if (informationDetail.getAae001().intValue() > 1997 && aae013.contains("定额缴费")) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条缴费起始时间在1998年1月及以后的记录，备注中不能含“定额缴费”字样");
            }
            if (informationDetail.getAae001().intValue() > 2009 && aae013.contains("曾办理异地转入")) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条缴费起始时间在2010年1月及以后的记录，备注中不能含“曾办理异地转入”字样");
            }
            if (informationDetail.getAae001().intValue() < 2010 && aae013.contains("临时缴费账户")) {
                throw new IllegalArgumentException("缴费明细中第" + i + "条缴费起始时间在2010年1月之前的记录，备注中不能含“临时缴费账户”字样");
            }

            if (aae382.compareTo(BigDecimal.ZERO) > 0 && informationDetail.getAae001().intValue() < year) {
                flag = true;
            }

            informationDetailMyMaps.add(MyMap.convertToMap(informationDetail));
            i++;
        }
        // 缴费记录按照结束期号排序
        //Collections.sort(informationDetailMyMaps, Comparator.comparing(a -> Integer.valueOf(a.get("aae042") + "")));
        /*校验当年记账金额*/
        // 1998-2005年之间的缴费记录
        List<MyMap> informationDetail1998TO2005 = informationDetailMyMaps.stream().filter(m -> m.getAsInteger("aae001") > 1997 && 2006 > m.getAsInteger("aae001")).collect(Collectors.toList());
        BigDecimal tmpTotal = BigDecimal.ZERO;
        for (MyMap myMap : informationDetail1998TO2005) {
            tmpTotal = BigDecimal.ZERO;
            if (myMap.getAsInteger("aae041").intValue() / 100 > 1997 && myMap.getAsInteger("aae042").intValue() / 100 < 2006) {
                aae180 = nullToBigdecimalZero((myMap.getAsBigDecimal("aae180")));
                aae202 = BigDecimalUtil.getBigDecimal(myMap.getAsInteger("aae042") - myMap.getAsInteger("aae041") + 1);

                tmpTotal = tmpTotal.add(aae180.multiply(aae202).multiply(new BigDecimal("0.11")));
                if (!ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae381"))) {
                    if (myMap.getAsBigDecimal("aae381").add(BigDecimal.ONE).compareTo(tmpTotal) < 0) {
                        throw new IllegalArgumentException(myMap.getAsString("aae001") + "年错误,【1998年至2005年的记录（不包括该期间补缴1998年前的记录），（当年记账金额+1）应≥∑月缴费基数×缴费月数×11%】");
                    } else {
//                        tmpTotal = BigDecimal.ZERO;
                    }
                }
            }

        }
        List<MyMap> informationDetail2005TOYearBefore = informationDetailMyMaps.stream().filter(m -> m.getAsInteger("aae001") > 2005 /*&& year > m.getAsInteger("aae001")*/).collect(Collectors.toList());

        for (MyMap myMap : informationDetail2005TOYearBefore) {
            tmpTotal = BigDecimal.ZERO;
            if (myMap.getAsInteger("aae041").intValue() / 100 > 2005) {
                aae180 = nullToBigdecimalZero((myMap.getAsBigDecimal("aae180")));
                aae202 = BigDecimalUtil.getBigDecimal(myMap.getAsInteger("aae042") - myMap.getAsInteger("aae041") + 1);
                tmpTotal = tmpTotal.add((aae180).multiply(aae202).multiply(new BigDecimal("0.08")));
                if (!ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae381")) && myMap.getAsBigDecimal("aae381").compareTo(BigDecimal.ZERO) > 0) {
                    if (myMap.getAsBigDecimal("aae381").add(BigDecimal.ONE).compareTo(tmpTotal) < 0) {
                        throw new IllegalArgumentException(myMap.getAsString("aae001") + "年错误,【2006年至调转上年的记录（不包括该期间补缴2006年前的记录），（当年记账金额+1）应≥∑月缴费基数×缴费月数×8%】");
                    } else {
//                        tmpTotal = BigDecimal.ZERO;
                    }
                }
            }

        }

        List<MyMap> informationDetailYearBefore = informationDetailMyMaps.stream().filter(m -> year > m.getAsInteger("aae001")).collect(Collectors.toList());
        if (!ValidateUtil.isEmpty(informationMyMap.getAic083())) {
            if (!ValidateUtil.isEmpty(informationDetailYearBefore)) {
                MyMap myMap = informationDetailYearBefore.get(informationDetailYearBefore.size() - 1);
                /*校验至本年末账户累计储存额*/
                if (ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae382"))) {
                    throw new IllegalArgumentException("如果个人账户基金转移额>0，调转当年之前如果有记录，则调转上年12月所在记录的至本年末账户累计储存额必须有值");
                }
                /*校验至本年末账户累计储存额中的个人缴费部分*/
                if (ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae273"))) {
                    throw new IllegalArgumentException("调转当年之前如果有记录，则调转上年12月所在记录的至本年末账户累计储存额中的个人缴费部分必须有值");
                }
            }
        }

        if (flag) {
            for (MyMap myMap : informationDetailMyMaps) {
                //调转上年末是否有12月台帐
                if (!ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae382")) && myMap.getAsBigDecimal("aae382").compareTo(BigDecimal.ZERO) > 0
                        && myMap.getAsInteger("aae001") == year - 1 && "12".equals(myMap.getAsInteger("aae042").toString().substring(4))) {
                    flag = false;
                    break;
                }
            }
        }

        if (flag) {
            throw new IllegalArgumentException("如果调转当年之前如果有台帐记录，则调转上年12月所在记录的至本年末账户累计储存额必须有值");
        }


        BigDecimal tmpAae382 = BigDecimal.ZERO;
        BigDecimal tmpAae273 = BigDecimal.ZERO;
        BigDecimal tmpAae381 = BigDecimal.ZERO;

        BigDecimal tmpAae264 = BigDecimal.ZERO;

        BigDecimal tmpAae269 = BigDecimal.ZERO;

        BigDecimal tmpAae265 = BigDecimal.ZERO;

        for (int j = 0; j < informationDetailMyMaps.size(); j++) {

            MyMap myMap = informationDetailMyMaps.get(j);

            tmpAae381 = ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae381")) ? BigDecimal.ZERO : myMap.getAsBigDecimal("aae381");
            tmpAae269 = ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae269")) ? BigDecimal.ZERO : myMap.getAsBigDecimal("aae269");
            tmpAae264 = ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae264")) ? BigDecimal.ZERO : myMap.getAsBigDecimal("aae264");
            tmpAae265 = ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae265")) ? BigDecimal.ZERO : myMap.getAsBigDecimal("aae265");

            if (tmpAae382.compareTo(BigDecimal.ZERO) > 0) {
                /*校验至本年末账户累计储存额*/
                if (!ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae382"))) {
                    if (myMap.getAsBigDecimal("aae382").compareTo(tmpAae382.add(tmpAae381).add(tmpAae269)) < 0) {
                        throw new IllegalArgumentException("第" + (j + 1) + "条至本年末账户累计储存额应≥至上年末账户累计储存额+当年记账金额+当年记账利息");
                    }
                    //tmpAae382 = myMap.getAsBigDecimal("aae382");
                }
                /*校验至本年末账户累计储存额中的个人缴费部分*/
                if (!ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae273"))) {
                    if (myMap.getAsBigDecimal("aae273").compareTo(tmpAae273.add(tmpAae264).add(tmpAae265)) < 0) {
                        throw new IllegalArgumentException("第" + (j + 1) + "条至本年末账户累计储存额中的个人缴费部分应≥至上年末账户累计储存额中的个人缴费部分+当年记账金额中的个人缴费部分+当年记账利息中的个人缴费部分");
                    }
                    //tmpAae273 = myMap.getAsBigDecimal("aae273");
                }
            }

            tmpAae382 = ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae382")) ? BigDecimal.ZERO : myMap.getAsBigDecimal("aae382");
            tmpAae273 = ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae273")) ? BigDecimal.ZERO : myMap.getAsBigDecimal("aae273");
            /*tmpAae381 = ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae381")) ? BigDecimal.ZERO : myMap.getAsBigDecimal("aae381");
            tmpAae269 = ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae269")) ? BigDecimal.ZERO : myMap.getAsBigDecimal("aae269");
            tmpAae264 = ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae264")) ? BigDecimal.ZERO : myMap.getAsBigDecimal("aae264");
            tmpAae265 = ValidateUtil.isEmpty(myMap.getAsBigDecimal("aae265")) ? BigDecimal.ZERO : myMap.getAsBigDecimal("aae265");*/

        }
        /*校验至本年末账户累计储存额*/
        // 校验连续记录最后一条含aae382
        for (int j = 0; j < informationDetailMyMaps.size(); j++) {

            if (informationDetailMyMaps.get(j).getAsString("aae013").contains("曾办理异地转入")) {
                if (!ValidateUtil.isEmpty(informationMyMap.getAac032())) {
                    if (informationDetailMyMaps.get(j).getAsInteger("aae001") > informationMyMap.getAac032().intValue() / 100) {
                        if (j + 1 < informationDetailMyMaps.size() && !(informationDetailMyMaps.get(j + 1).getAsString("aae013").contains("曾办理异地转入"))
                                && ValidateUtil.isEmpty(informationDetailMyMaps.get(j).getAsBigDecimal("aae382"))) {
                            throw new IllegalArgumentException("备注含“曾办理异地转入”字样的连续记录的最后一条，至本年末账户累计储存额必须有值");
                        }
                    }
                    if (j == informationDetailMyMaps.size() - 1 && ValidateUtil.isEmpty(informationDetailMyMaps.get(j).getAsBigDecimal("aae382"))) {
                        throw new IllegalArgumentException("备注含“曾办理异地转入”字样的连续记录的最后一条，至本年末账户累计储存额必须有值");
                    }
                }

            }

        }
    }

    /**
     * 军队信息表校验
     *
     * @param informationInfo
     * @param informationOtherInfos
     * @param detailInfos
     */
    @Override
    public void checkinfromationOfSoldier(InformationInfo informationInfo, List<InformationOtherInfo> informationOtherInfos, List<InformationDetailInfo> detailInfos) {

        NPETool.isEmptyThrowException(informationInfo, "信息表信息");
        NPETool.isEmptyThrowException(informationOtherInfos, "信息表附表信息");
        NPETool.isEmptyThrowException(detailInfos, "信息表附表信息");
        Ic96Info ic96Info = (Ic96Info) informationInfo;
        Ic95Info ic95Info = (Ic95Info) informationOtherInfos.get(0);


//        int zyny = Integer.valueOf(ic96Info.getAae035().toString().substring(0, 6));
        int zydn = Integer.valueOf(ic96Info.getAae035().toString().substring(0, 4));
        int dqny = Integer.valueOf(DateUtil.getCurrentTime("yyyyMM"));


        List<Integer> allYear = new ArrayList<>();

        // 临时变量，校验重复导入人员信息
        Set<Ic97Info> tempSet = new HashSet<>();


        StringBuilder errorBuilder;

        Integer aae041 = 0;
        Integer aae042 = 0;

        Integer aae202_ze = 0;//总月数
        BigDecimal aic099_ze = BigDecimal.ZERO;//个人总额
        BigDecimal aic084_ze = BigDecimal.ZERO;//单位总额
        BigDecimal aae269_ze = BigDecimal.ZERO;//利息总额
        BigDecimal aic099_jr = ic95Info.getAic099();
        BigDecimal aic084_jr = ic95Info.getAic084();
        BigDecimal aic102_jr = ic95Info.getAic102();
        BigDecimal aic135_jr = ic95Info.getAic135();

        Ic97Info ic97Info;
        for (int i = 0; i < detailInfos.size(); i++) {
            ic97Info = (Ic97Info) detailInfos.get(i);
            errorBuilder = new StringBuilder();

            if (i == 0) {
                aae041 = ic97Info.getAae041();
            }
            if (i == detailInfos.size() - 1) {
                aae042 = ic97Info.getAae042();
            }
            allYear.add(ic97Info.getAae001());
            StringBuilder builder = new StringBuilder();
            if (ValidateUtil.isEmpty(ic97Info.getAae001())) {
                builder.append("年份不能为空；");
            }
            if (ValidateUtil.isEmpty(ic97Info.getAae041())) {
                builder.append("缴费开始年月不能为空；");
            }
            if (ValidateUtil.isEmpty(ic97Info.getAae042())) {
                builder.append("缴费终止年月不能为空；");
            }
            if (ValidateUtil.isEmpty(ic97Info.getAae202())) {
                builder.append("缴费月数不能为空；");
            }
            if (ValidateUtil.isEmpty(ic97Info.getAic102())) {
                builder.append("军人退役养老保险补助不能为空；");
            }
            if (ValidateUtil.isEmpty(ic97Info.getAic084())) {
                builder.append("军人退役养老保险补助中的单位缴费（12%）不能为空；");
            }
            if (ValidateUtil.isEmpty(ic97Info.getAic099())) {
                builder.append("军人退役养老保险补助中的个人缴（8%）不能为空；");
            }
            if (!ValidateUtil.isEmpty(ic97Info.getAae001())) {
                if ((ic97Info.getAae001().toString().length() != 6 && ic97Info.getAae001().toString().length() != 4)) {
                    builder.append("年份格式不正确；");
                } else if (Integer.parseInt(ic97Info.getAae001().toString().substring(0, 4)) > Integer.parseInt(ic96Info.getAae035().toString().substring(0, 4))) {
                    builder.append("年份不可晚于转移年度；");
                } else if (ic97Info.getAae001().toString().length() == 6 && (Integer.valueOf(ic97Info.getAae001().toString().substring(4, 6)) == 0 || Integer.valueOf(ic97Info.getAae001().toString().substring(4, 6)) > 12)) {
                    builder.append("年份格式不正确；");
                }
            }
            if (!ValidateUtil.isEmpty(ic97Info.getAae041())) {
                if (ic97Info.getAae041().toString().length() != 6) {//格式为YYYYMM的有效年月
                    builder.append("开始年月为6位数字；");
                } else if (Integer.valueOf(ic97Info.getAae041().toString().substring(4, 6)) == 0 || Integer.valueOf(ic97Info.getAae041().toString().substring(4, 6)) > 12) {
                    builder.append("开始年月格式不正确；");
                }
                if (ic97Info.getAae041() > ic97Info.getAae042()) {//早于或等于缴费终止时间
                    builder.append("开始年月不能晚于终止年月；");
                }
            }
            if (!ValidateUtil.isEmpty(ic97Info.getAae042())) {
                if (ic97Info.getAae042().toString().length() != 6) {//格式为YYYYMM的有效年月
                    builder.append("结束年月为6位数字；");
                } else if (Integer.valueOf(ic97Info.getAae042().toString().substring(4, 6)) == 0 || Integer.valueOf(ic97Info.getAae042().toString().substring(4, 6)) > 12) {
                    builder.append("结束年月格式不正确；");
                } else if (ic97Info.getAae042() > dqny) {//早于或等于系统当前年月
                    builder.append("结束年月不能晚于当前年月；");
                }
            }
            if (!ValidateUtil.isEmpty(ic97Info.getAae041()) && !ValidateUtil.isEmpty(ic97Info.getAae042()) &&
                    !ic97Info.getAae042().toString().substring(0, 4).equals(ic97Info.getAae041().toString().substring(0, 4))) {
                builder.append("缴费开始时间和缴费终止时间不在同一年度；");//缴费终止时间应与缴费起始时间在同一自然年
            }
          /*  if (!ValidateUtil.isEmpty(ic97Info.getAae041()) && !ValidateUtil.isEmpty(ic97Info.getAae042()) && !ValidateUtil.isEmpty(ic97Info.getAae202())) {
                long monthBetween = DateUtil.getBetweenCountIssue(ic97Info.getAae041(), ic97Info.getAae042());
                if (ic97Info.getAae202() != monthBetween) {//缴费月数=缴费终止时间-缴费起始时间+1，或者为0
                    builder.append("缴费月数=缴费终止时间-缴费起始时间+1；");
                }
            }*/
            BigDecimal monNum = new BigDecimal(DateUtil.getBetweenCountIssue(ic97Info.getAae041(), ic97Info.getAae042()));
            if (!ValidateUtil.isEmpty(ic97Info.getAic084()) && !ValidateUtil.isEmpty(ic97Info.getAae180())) {  //允许上下浮动1块
                if (!(ic97Info.getAic084().add(BigDecimal.ONE).compareTo(ic97Info.getAae180().multiply(new BigDecimal("0.12")).multiply(monNum).setScale(2, BigDecimal.ROUND_HALF_UP)) > 0 &&
                        ic97Info.getAic084().subtract(BigDecimal.ONE).compareTo(ic97Info.getAae180().multiply(new BigDecimal("0.12")).multiply(monNum).setScale(2, BigDecimal.ROUND_HALF_UP)) < 0
                )) {
                    builder.append("军人退役养老保险补助中的单位缴费（12%）应= 工资*0.12；");
                }
            }
            if (!ValidateUtil.isEmpty(ic97Info.getAic099()) && !ValidateUtil.isEmpty(ic97Info.getAae180())) {//允许上下浮动1块
                if (!(ic97Info.getAic099().add(BigDecimal.ONE).compareTo(ic97Info.getAae180().multiply(new BigDecimal("0.08")).multiply(monNum).setScale(2, BigDecimal.ROUND_HALF_UP)) > 0 &&
                        ic97Info.getAic099().subtract(BigDecimal.ONE).compareTo(ic97Info.getAae180().multiply(new BigDecimal("0.08")).multiply(monNum).setScale(2, BigDecimal.ROUND_HALF_UP)) < 0
                )) {
                    builder.append("军人退役养老保险补助中的个人缴费（8%）应= 工资*0.08；");
                }
            }
            //if (!ValidateUtil.isEmpty(ic97Info.getAic099()) && !ValidateUtil.isEmpty(this.aae269)) {
            //    if (this.aic102.compareTo(ic97Info.getAic084().add(ic97Info.getAic099()).add(this.aae269)) != 0) {
            //        builder.append("军人退役养老保险补助（小计）=军人退役养老保险补助中的单位缴费（12%）+军人退役养老保险补助中的个人缴费（8%）+个人当年缴费利息；");
            //    }
            //}

            if (!ValidateUtil.isEmpty(ic97Info.getAic084()) && !ValidateUtil.isEmpty(ic97Info.getAae180())) {
                if (ic97Info.getAic084().compareTo(ic97Info.getAae180().multiply(new BigDecimal("0.12")).multiply(new BigDecimal(ic97Info.getAae202())).add(BigDecimal.ONE).setScale(2, BigDecimal.ROUND_HALF_UP)) > 0
                        || ic97Info.getAic084().compareTo(ic97Info.getAae180().multiply(new BigDecimal("0.12")).subtract(BigDecimal.ONE).setScale(2, BigDecimal.ROUND_HALF_UP)) < 0) {
                    builder.append("军人退役养老保险补助中的单位缴费（12%）应= 工资*月数*0.12；");
                }
            }
            if (!ValidateUtil.isEmpty(ic97Info.getAic099()) && !ValidateUtil.isEmpty(ic97Info.getAae180())) {
                if (!(ic97Info.getAic099().compareTo(ic97Info.getAae180().multiply(new BigDecimal("0.08")).multiply(new BigDecimal(ic97Info.getAae202())).add(BigDecimal.ONE).setScale(2, BigDecimal.ROUND_HALF_UP)) < 0
                        && ic97Info.getAic099().compareTo(ic97Info.getAae180().multiply(new BigDecimal("0.08")).multiply(new BigDecimal(ic97Info.getAae202())).subtract(BigDecimal.ONE).setScale(2, BigDecimal.ROUND_HALF_UP)) > 0)) {
                    builder.append("军人退役养老保险补助中的个人缴费（8%）应= 工资*月数*0.08；");
                }
            }
            if (!ValidateUtil.isEmpty(ic97Info.getAic099()) && !ValidateUtil.isEmpty(ic97Info.getAae269())) {
                if (ic97Info.getAic102().compareTo(ic97Info.getAic084().add(ic97Info.getAic099()).add(ic97Info.getAae269())) != 0) {
                    builder.append("军人退役养老保险补助（小计）应=军人退役养老保险补助中的单位缴费（12%）+军人退役养老保险补助中的个人缴费（8%）+个人当年缴费利息；");
                }
            }

            if (ic97Info.getAae202() != 0) {//缴费月数不为0时，不能有相同缴费起止时间段的缴费记录
                for (int j = i + 1; j < detailInfos.size(); j++) {
                    if (((Ic97Info) detailInfos.get(j)).getAae202().intValue() != 0) {
                        if ((ic97Info.getAae041().intValue() <= ((Ic97Info) detailInfos.get(j)).getAae041().intValue() && ic97Info.getAae042().intValue() >= ((Ic97Info) detailInfos.get(j)).getAae041().intValue())
                                || (ic97Info.getAae041().intValue() <= ((Ic97Info) detailInfos.get(j)).getAae042().intValue() && ic97Info.getAae042().intValue() >= ((Ic97Info) detailInfos.get(j)).getAae042().intValue())) {//判定是否有交集
                            errorBuilder.append("缴费月数不为0时，不能有缴费时间段交叉的缴费记录；");
                        }
                    }
                }
            }
            if (ValidateUtil.isEmpty(errorBuilder.toString()) && !tempSet.add(ic97Info)) { // 校验重复
                errorBuilder.append("该列为重复列；");
            }
            if (ValidateUtil.isNotEmpty(errorBuilder.toString())) { // 校验失败
                throw new IllegalArgumentException("第" + (i + 1) + "条：" + errorBuilder.toString());
            }
            if (ValidateUtil.isNotEmpty(builder.toString())) { //校验失败
                throw new IllegalArgumentException("第" + (i + 1) + "条：" + builder.toString());
            }


            aic099_ze = aic099_ze.add(ValidateUtil.isEmpty(ic97Info.getAic099()) ? BigDecimal.ZERO : ic97Info.getAic099());
            aae269_ze = aae269_ze.add(ValidateUtil.isEmpty(ic97Info.getAae269()) ? BigDecimal.ZERO : ic97Info.getAae269());
            aic084_ze = aic084_ze.add(ValidateUtil.isEmpty(ic97Info.getAic084()) ? BigDecimal.ZERO : ic97Info.getAic084());
            aae202_ze = aae202_ze + (ValidateUtil.isEmpty(ic97Info.getAae202()) ? 0 : ic97Info.getAae202());
        }

        if (aic099_jr.compareTo(aic099_ze) != 0) {
            throw new IllegalArgumentException("累加：（军人退役养老保险补助中的个人缴费（8%） ）" + aic099_ze + "  应等于个人缴费金额");
        }
        if (aic135_jr.compareTo(aae269_ze) != 0) {
            throw new IllegalArgumentException("累加：（军人退役养老保险补助中的个人缴费利息 ）" + aae269_ze + "  应等于个人缴费利息");
        }
        if (aic084_jr.compareTo(aic084_ze) != 0) {
            throw new IllegalArgumentException("累加：（军人退役养老保险补助中的单位缴费（12%）" + aic084_ze + "  应等于单位缴费金额");
        }
        BigDecimal aic102 = aic084_jr.add(aic099_jr).add(aic135_jr);
        if (aic102.compareTo(aic102_jr) != 0) {
            throw new IllegalArgumentException("单位缴费+个人缴费+利息" + aic102 + "  不等于军人养老保险补助总额" + aic102_jr);
        }

        if ((aae041.intValue() != ic95Info.getAae041().intValue()) && ic95Info.getAae140().equals(Constant.AAE140_110_QYZGJBYLBX)) {
            throw new IllegalArgumentException("服现役起始时间:" + aae041 + "应等于最早缴费明细开始时间:" + ic95Info.getAae041());
        }
        if (aae042.intValue() != ic95Info.getAae042().intValue()) {
            throw new IllegalArgumentException("服现役终止时间:" + aae042 + "应等于最晚缴费明细结束时间:" + ic95Info.getAae042());
        }
        if (aae202_ze.intValue() != ic95Info.getAae201().intValue()) {
            throw new IllegalArgumentException("在军队实际缴费月数:" + ic95Info.getAae201() + "应等于缴费明细累加月数:" + aae202_ze);
        }


        // 校验 年份是否连续
        int beforeTransferYear = zydn - 1;
/*        if (!(((Ic97Info) detailInfos.get(0)).getAae001().intValue() >= beforeTransferYear)) {
            List<Integer> allAae001 = DateUtil.getBetweenAllYear(((Ic97Info) detailInfos.get(0)).getAae001().intValue(), beforeTransferYear);
            for (Integer aae001 : allAae001) {
                if (!allYear.contains(aae001)) {
                    throw new IllegalArgumentException("从历史信息首条记录的缴费起始时间到调转(转出日期)上年，年份应连续（即不存在没有记录的年份）");
                }
            }
        }*/

    }


    /**
     * 校验转移在途业务
     *
     * @param aac001
     * @return
     */
    @Override
    public boolean checkTransferRoute(String aac001) {

        NPETool.isEmptyThrowException(aac001, "人员编号");


        boolean flag = false;

        Map q = new HashMap();
        q.put("aac001", aac001);
        q.put("aae016", Constant.AAE016_0_WSH);
        List<String> aaa121s = new ArrayList<>();

        q.put("aaa121s", aaa121s);
//            List<Map> ae02List = RepositoryRegister.businessLogRepository().getAE02A1(q);
        List<Map> ae02List = new ArrayList<>();
        if (ValidateUtil.isNotEmpty(ae02List)) {
            flag = true;
        }


//            List<Map> process = RepositoryRegister.transferRepository().queryProcessInfo(q);
        List<Map> process = new ArrayList<>();
        if (ValidateUtil.isNotEmpty(process)) {
            for (Map p : process) {
                if (!(Constant.AAE802_2_YBJ.equals(p.get("aae802")) || Constant.AAE802_3_ZZ.equals(p.get("aae802")))) {
                    flag = true;
                }
            }
        }

        return flag;
    }

    /**
     * 校验是否多号
     *
     * @param aac002 证件号码
     */
    @Override
    public void checkDH(String aac002, String aac001, String aae140) {
        Map map = new HashMap();
        map.put("aac002", aac002);
        map.put("aac320", Constant.AAC320_1_YX);
//            List<Map> ac01List = NationalQueryRegister.einpBasicinfoQueryService().getAC01(map);
        List<Map> ac01List = new ArrayList<>();
        if (ValidateUtil.isNotEmpty(ac01List)) {
            if (ac01List.size() > 1) {
                throw new IllegalArgumentException("该参保人" + aac002 + "为多号人员，请先进行多号合并！");
            }
        }

    }

    /**
     * 校验是否多号
     *
     * @param aac001 证件号码
     */
    @Override
    public void checkDH_excludeAac008(String aac001, String aae140, List<Map> ac01List) {
        Map map = new HashMap();
        for (Map ac01 : ac01List) {
            if (!aac001.equals(ac01.get("aac001").toString())) {
                map.put("aac001", ac01.get("aac001"));
                map.put("aae140", aae140);
//                    List<Map> ac02s = NationalQueryRegister.einpBasicinfoQueryService().getAC02(map);
                List<Map> ac02s = new ArrayList<>();
                if (!ValidateUtil.isEmpty(ac02s)) {
                    for (Map ac02 : ac02s) {
                        if (!Constant.AAC008_4_ZZCB.equals(ac02.get("aac008"))) {//排除终止参保的
                            throw new IllegalArgumentException("该参保人" + aac001 + "为多号人员，请先进行多号合并！");
                        }
                    }

                }

            }
        }

    }

    /**
     * 校验是否办理转出
     *
     * @param aae270 联系函编号
     * @param aac002 证件号码
     */
    @Override
    public void checkOut(String aae270, String aac002) {
        Map map = new HashMap();
        map.put("aac002", aac002);
        map.put("aae270", aae270);
//        Map ac10 = RepositoryRegister.transferRepository().getAC10(map).get(0);

        if (ValidateUtil.isNotEmpty("")) {
            throw new IllegalArgumentException("该参保人" + aac002 + "的联系函" + aae270 + "已经使用过！");
        }
    }

    /**
     * 云南特殊校验是否多号
     *
     * @param aac002 证件号码
     */
    @Override
    public void checkDHYN(String aac002) {
        int[] a = {110, 120};
        for (int i : a) {
            HashMap map = new HashMap();
            map.put("aac002", aac002);
            map.put("aac320", Constant.AAC320_1_YX);
            map.put("aae140", i);
//                List<Map> ac01List = NationalQueryRegister.einpBasicinfoQueryService().checkAc01Ac02(map);
            List<Map> ac01List = new ArrayList<>();
            if (ValidateUtil.isNotEmpty(ac01List)) {
                if (ac01List.size() > 1) {
                    throw new IllegalArgumentException("该参保人" + aac002 + "为多号人员，请先进行多号合并！");
                }
            }
        }
    }

    /**
     * 校验养老保险关系转入后是否已匹配基金
     *
     * @param aac002
     */
    @Override
    public void checkTransferInNoMatch(String aac002) {
        Map map = new HashMap();
        map.put("aac002", aac002);
        map.put("aae733", Constant.AAE733_0_F);
        map.put("aac306", Constant.AAC306_2_YD);
//            List<Map> ic90s = NationalQueryRegister.einpEinpSettleQueryService().getIC90(map);
//            List<Map> ic66s = NationalQueryRegister.einpEinpSettleQueryService().getIC66(map);
//            List<Map> ic72s = NationalQueryRegister.einpEinpSettleQueryService().getIC72(map);
//            List<Map> ic96s = NationalQueryRegister.einpEinpSettleQueryService().getIC96(map);
//            if (ValidateUtil.isNotEmpty(ic90s) || ValidateUtil.isNotEmpty(ic66s) || ValidateUtil.isNotEmpty(ic72s) || ValidateUtil.isNotEmpty(ic96s)) {
//                throw new IllegalArgumentException("该参保人" + aac002 + "存在未匹配基金的转入信息，请核实！");
//            }
    }


    /**
     * 转移账户校验
     *
     * @param aac001 个人编号
     * @param aae140 险种类型
     */
    @Override
    public void checkTransAccount(String aac001, String aae140) {
        Map map = new HashMap();
        map.put("aac001", aac001);
        map.put("aae140", aae140);
        Map ac51map = new HashMap<>();

//            List<Map> maps = NationalQueryRegister.einpCollectionQueryService().queryAc08(map);
        List<Map> maps = new ArrayList<>();
        List<Map> collect = maps.stream().filter(ac08 -> ac08.get("aae793").equals(Constant.AAE793_1061_ZR) || ac08.get("aae793").equals(Constant.AAE793_1062_JGZR) || ac08.get("aae793").equals(Constant.AAE793_1063_CXZR) || ac08.get("aae793").equals(Constant.AAE793_1064_JRZR)).collect(Collectors.toList());
        Map<String, List<Map>> ac08GroupMap = collect.stream().collect(Collectors.groupingBy(ac08 -> ValidateUtil.isEmpty(ac08.get("aae819")) ? "" : ac08.get("aae819").toString()));
        for (Map.Entry<String, List<Map>> entry : ac08GroupMap.entrySet()) {
            List<Map> value = entry.getValue();
            if (value.size() > 1) {//只有一条明细的转移不校验
                HashSet<String> set = new HashSet<>();
                for (Map map1 : value) {
                    ac51map.put("aab191", map1.get("aab191").toString());
                    set.add(map1.get("aab191").toString());
                }
                if (set.size() == 1) {
                    ac51map.put("aaz116", entry.getKey());
//                        List<Map> ac51s = NationalQueryRegister.einpCollectionQueryService().getAC51ByAaz116(ac51map);
                    List<Map> ac51s = new ArrayList<>();

                    List<Map> details = ac51s.stream().filter(ac51 -> !"转移账户计息".equals(NPETool.isEmptyReturnString(ac51.get("aae013")))).collect(Collectors.toList());//过滤出所有转移的台账，不含转入后计息的
                    BigDecimal aae265 = details.stream().map(detail -> new BigDecimal(detail.get("aae265").toString())).reduce(BigDecimal.ZERO, BigDecimal::add);
                    if (aae265.compareTo(BigDecimal.ZERO) != 0) {//全部转移是补缴的不校验

                        throw new IllegalArgumentException("在职个人账户ID为:" + entry.getKey() + "的转移账户到账年月全部都是" + ac51map.get("aab191") + "，请到异常账户处理功能删除错误的转移账户并重新录入保存复核，操作后，查看账户没有问题在办理转出登记");
                    }
                }
            }

        }

    }


    /**
     * @param aac001:
     * @param aaz159:
     * @Description: 存在手工缴费校验
     * @author LZW
     * @return: void
     * @date 2023/5/30 20:24
     */
    @Override
    public void checkTransAc08(String aac001, String aaz159, String aae140) {

        Map param = new HashMap();

        param.put("aac001", aac001);
        param.put("aae140", aae140);
        param.put("aaz159", aaz159);
        param.put("isNotTf", 1);
        param.put("tyjrzhdy", "1");
        param.put("pclxtqfbj", "1");

        List<String> list = Arrays.asList(Constant.AAE741_3_SJWH, Constant.AAE741_8_FZSSR);
//            List<Map> payments = NationalQueryRegister.einpCollectionQueryService().getAC08(param);
        List<Map> payments = new ArrayList<>();
        List<Map> ac08s = payments.stream().filter(ac08 -> list.contains(ac08.get("aae741").toString())).collect(Collectors.toList());
        Integer aae202 = ac08s.stream().mapToInt(ac08 -> Integer.parseInt(ac08.get("aae202").toString())).sum();
        if (aae202 > 12) {//全部转移是补缴的不校验
            throw new IllegalArgumentException("该人员进行特殊历史缴费明细补录且补录月数超过12个月");
        }

    }


    /**
     * 转出登记缴费基数和信息表基数和不一致校验
     *
     * @param aac001
     * @param aaz159
     * @param aae140
     */
    @Override
    public void checkTransAae180(String aac001, String aaz159, String aae140, List<Map> informationDetails) {

        Map param = new HashMap();

        param.put("aac001", aac001);
        param.put("aae140", aae140);
        param.put("aaz159", aaz159);
        param.put("isNotTf", 1);
        param.put("tyjrzhdy", "1");
        param.put("pclxtqfbj", "1");

//            List<Map> payments = NationalQueryRegister.einpCollectionQueryService().getAC08(param);
        List<Map> payments = new ArrayList<>();
        BigDecimal ac08_aae180 = payments.stream().map(map -> new BigDecimal(map.get("aae180").toString())).reduce(BigDecimal.ZERO, BigDecimal::add);
        BigDecimal xxb_aae180 = informationDetails.stream().map(map -> new BigDecimal(map.get("aae180").toString()).multiply(new BigDecimal(Integer.parseInt(map.get("aae042").toString()) - Integer.parseInt(map.get("aae041").toString()) + 1))).reduce(BigDecimal.ZERO, BigDecimal::add);

        if (ac08_aae180.compareTo(xxb_aae180) != 0) {//信息表基数和明细基数和不一致
            throw new IllegalArgumentException("转出基金总额和信息表总额不一致!!!");
        }

    }


    private BigDecimal nullToBigdecimalZero(BigDecimal bigDecimal) {
        return ValidateUtil.isEmpty(bigDecimal) ? BigDecimal.ZERO : bigDecimal;
    }

    @Override
    public void checkAac008(String aac001, String aae140) {

        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("aac001",aac001);
        queryWrapper.eq("aae140",aae140);
        queryWrapper.eq("aac008",Constant.AAC008_1_ZCCB);
        queryWrapper.in("aac031",Constant.AAC031_1_CBJF,Constant.AAC031_2_ZTJF,Constant.AAC031_3_ZZJF);
        List<Map> ac02 = basicAc02Service.list(queryWrapper);
        if (ValidateUtil.isEmpty(ac02)) {
            throw new IllegalArgumentException("人员参保状态异常");
        }
    }


}


